hotspot/src/share/vm/ci/ciMethodBlocks.cpp
Print this page
rev 611 : Merge
*** 1,10 ****
#ifdef USE_PRAGMA_IDENT_SRC
#pragma ident "@(#)ciMethodBlocks.cpp 1.6 07/09/28 10:23:22 JVM"
#endif
/*
! * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,10 ----
#ifdef USE_PRAGMA_IDENT_SRC
#pragma ident "@(#)ciMethodBlocks.cpp 1.6 07/09/28 10:23:22 JVM"
#endif
/*
! * Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 50,60 ****
// Split the block spanning bci into two separate ranges. The former
// block becomes the second half and a new range is created for the
// first half. Returns the range beginning at bci.
ciBlock *ciMethodBlocks::split_block_at(int bci) {
ciBlock *former_block = block_containing(bci);
! ciBlock *new_block = new(_arena) ciBlock(_method, _num_blocks++, this, former_block->start_bci());
_blocks->append(new_block);
assert(former_block != NULL, "must not be NULL");
new_block->set_limit_bci(bci);
former_block->set_start_bci(bci);
for (int pos=bci-1; pos >= 0; pos--) {
--- 50,60 ----
// Split the block spanning bci into two separate ranges. The former
// block becomes the second half and a new range is created for the
// first half. Returns the range beginning at bci.
ciBlock *ciMethodBlocks::split_block_at(int bci) {
ciBlock *former_block = block_containing(bci);
! ciBlock *new_block = new(_arena) ciBlock(_method, _num_blocks++, former_block->start_bci());
_blocks->append(new_block);
assert(former_block != NULL, "must not be NULL");
new_block->set_limit_bci(bci);
former_block->set_start_bci(bci);
for (int pos=bci-1; pos >= 0; pos--) {
*** 68,86 ****
} else {
// We are done with our backwards walk
break;
}
}
return former_block;
}
ciBlock *ciMethodBlocks::make_block_at(int bci) {
ciBlock *cb = block_containing(bci);
if (cb == NULL ) {
// This is our first time visiting this bytecode. Create
// a fresh block and assign it this starting point.
! ciBlock *nb = new(_arena) ciBlock(_method, _num_blocks++, this, bci);
_blocks->append(nb);
_bci_to_block[bci] = nb;
return nb;
} else if (cb->start_bci() == bci) {
// The block begins at bci. Simply return it.
--- 68,94 ----
} else {
// We are done with our backwards walk
break;
}
}
+ // Move an exception handler information if needed.
+ if (former_block->is_handler()) {
+ int ex_start = former_block->ex_start_bci();
+ int ex_end = former_block->ex_limit_bci();
+ new_block->set_exception_range(ex_start, ex_end);
+ // Clear information in former_block.
+ former_block->clear_exception_handler();
+ }
return former_block;
}
ciBlock *ciMethodBlocks::make_block_at(int bci) {
ciBlock *cb = block_containing(bci);
if (cb == NULL ) {
// This is our first time visiting this bytecode. Create
// a fresh block and assign it this starting point.
! ciBlock *nb = new(_arena) ciBlock(_method, _num_blocks++, bci);
_blocks->append(nb);
_bci_to_block[bci] = nb;
return nb;
} else if (cb->start_bci() == bci) {
// The block begins at bci. Simply return it.
*** 91,100 ****
--- 99,113 ----
// be split into two.
return split_block_at(bci);
}
}
+ ciBlock *ciMethodBlocks::make_dummy_block() {
+ ciBlock *dum = new(_arena) ciBlock(_method, -1, 0);
+ return dum;
+ }
+
void ciMethodBlocks::do_analysis() {
ciBytecodeStream s(_method);
ciBlock *cur_block = block_containing(0);
int limit_bci = _method->code_size();
*** 103,113 ****
// Determine if a new block has been made at the current bci. If
// this block differs from our current range, switch to the new
// one and end the old one.
assert(cur_block != NULL, "must always have a current block");
ciBlock *new_block = block_containing(bci);
! if (new_block == NULL) {
// We have not marked this bci as the start of a new block.
// Keep interpreting the current_range.
_bci_to_block[bci] = cur_block;
} else {
cur_block->set_limit_bci(bci);
--- 116,126 ----
// Determine if a new block has been made at the current bci. If
// this block differs from our current range, switch to the new
// one and end the old one.
assert(cur_block != NULL, "must always have a current block");
ciBlock *new_block = block_containing(bci);
! if (new_block == NULL || new_block == cur_block) {
// We have not marked this bci as the start of a new block.
// Keep interpreting the current_range.
_bci_to_block[bci] = cur_block;
} else {
cur_block->set_limit_bci(bci);
*** 246,272 ****
int b2bsize = _code_size * sizeof(ciBlock **);
_bci_to_block = (ciBlock **) arena->Amalloc(b2bsize);
Copy::zero_to_words((HeapWord*) _bci_to_block, b2bsize / sizeof(HeapWord));
// create initial block covering the entire method
! ciBlock *b = new(arena) ciBlock(_method, _num_blocks++, this, 0);
_blocks->append(b);
_bci_to_block[0] = b;
// create blocks for exception handlers
if (meth->has_exception_handlers()) {
for(ciExceptionHandlerStream str(meth); !str.is_done(); str.next()) {
ciExceptionHandler* handler = str.handler();
ciBlock *eb = make_block_at(handler->handler_bci());
! eb->set_handler();
int ex_start = handler->start();
int ex_end = handler->limit();
- eb->set_exception_range(ex_start, ex_end);
// ensure a block at the start of exception range and start of following code
(void) make_block_at(ex_start);
if (ex_end < _code_size)
(void) make_block_at(ex_end);
}
}
// scan the bytecodes and identify blocks
do_analysis();
--- 259,310 ----
int b2bsize = _code_size * sizeof(ciBlock **);
_bci_to_block = (ciBlock **) arena->Amalloc(b2bsize);
Copy::zero_to_words((HeapWord*) _bci_to_block, b2bsize / sizeof(HeapWord));
// create initial block covering the entire method
! ciBlock *b = new(arena) ciBlock(_method, _num_blocks++, 0);
_blocks->append(b);
_bci_to_block[0] = b;
// create blocks for exception handlers
if (meth->has_exception_handlers()) {
for(ciExceptionHandlerStream str(meth); !str.is_done(); str.next()) {
ciExceptionHandler* handler = str.handler();
ciBlock *eb = make_block_at(handler->handler_bci());
! //
! // Several exception handlers can have the same handler_bci:
! //
! // try {
! // if (a.foo(b) < 0) {
! // return a.error();
! // }
! // return CoderResult.UNDERFLOW;
! // } finally {
! // a.position(b);
! // }
! //
! // The try block above is divided into 2 exception blocks
! // separated by 'areturn' bci.
! //
int ex_start = handler->start();
int ex_end = handler->limit();
// ensure a block at the start of exception range and start of following code
(void) make_block_at(ex_start);
if (ex_end < _code_size)
(void) make_block_at(ex_end);
+
+ if (eb->is_handler()) {
+ // Extend old handler exception range to cover additional range.
+ int old_ex_start = eb->ex_start_bci();
+ int old_ex_end = eb->ex_limit_bci();
+ if (ex_start > old_ex_start)
+ ex_start = old_ex_start;
+ if (ex_end < old_ex_end)
+ ex_end = old_ex_end;
+ eb->clear_exception_handler(); // Reset exception information
+ }
+ eb->set_exception_range(ex_start, ex_end);
}
}
// scan the bytecodes and identify blocks
do_analysis();
*** 303,325 ****
}
}
#endif
! ciBlock::ciBlock(ciMethod *method, int index, ciMethodBlocks *mb, int start_bci) :
#ifndef PRODUCT
_method(method),
#endif
_idx(index), _flags(0), _start_bci(start_bci), _limit_bci(-1), _control_bci(fall_through_bci),
_ex_start_bci(-1), _ex_limit_bci(-1) {
}
void ciBlock::set_exception_range(int start_bci, int limit_bci) {
assert(limit_bci >= start_bci, "valid range");
! assert(is_handler(), "must be handler");
_ex_start_bci = start_bci;
_ex_limit_bci = limit_bci;
}
#ifndef PRODUCT
static const char *flagnames[] = {
"Processed",
--- 341,364 ----
}
}
#endif
! ciBlock::ciBlock(ciMethod *method, int index, int start_bci) :
#ifndef PRODUCT
_method(method),
#endif
_idx(index), _flags(0), _start_bci(start_bci), _limit_bci(-1), _control_bci(fall_through_bci),
_ex_start_bci(-1), _ex_limit_bci(-1) {
}
void ciBlock::set_exception_range(int start_bci, int limit_bci) {
assert(limit_bci >= start_bci, "valid range");
! assert(!is_handler() && _ex_start_bci == -1 && _ex_limit_bci == -1, "must not be handler");
_ex_start_bci = start_bci;
_ex_limit_bci = limit_bci;
+ set_handler();
}
#ifndef PRODUCT
static const char *flagnames[] = {
"Processed",