This commit is contained in:
Claes Redestad 2017-05-17 12:46:12 +00:00
commit 3725b7c8ff
8 changed files with 56 additions and 224 deletions

View File

@ -623,9 +623,7 @@ csize_t CodeBuffer::total_offset_of(const CodeSection* cs) const {
}
csize_t CodeBuffer::total_relocation_size() const {
csize_t lsize = copy_relocations_to(NULL); // dry run only
csize_t csize = total_content_size();
csize_t total = RelocIterator::locs_and_index_size(csize, lsize);
csize_t total = copy_relocations_to(NULL); // dry run only
return (csize_t) align_size_up(total, HeapWordSize);
}
@ -726,13 +724,6 @@ csize_t CodeBuffer::copy_relocations_to(CodeBlob* dest) const {
//
buf_offset = copy_relocations_to(buf, buf_limit, false);
// Account for index:
if (buf != NULL) {
RelocIterator::create_index(dest->relocation_begin(),
buf_offset / sizeof(relocInfo),
dest->relocation_end());
}
return buf_offset;
}

View File

@ -131,14 +131,6 @@ RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_
: CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */)
{
assert(locs_size == round_to(locs_size, oopSize), "unaligned size");
assert(!UseRelocIndex, "no space allocated for reloc index yet");
// Note: If UseRelocIndex is enabled, there needs to be (at least) one
// extra word for the relocation information, containing the reloc
// index table length. Unfortunately, the reloc index table imple-
// mentation is not easily understandable and thus it is not clear
// what exactly the format is supposed to be. For now, we just turn
// off the use of this table (gri 7/6/2000).
}

View File

@ -2357,26 +2357,6 @@ void nmethod::print_relocations() {
tty->print_cr("relocations:");
RelocIterator iter(this);
iter.print();
if (UseRelocIndex) {
jint* index_end = (jint*)relocation_end() - 1;
jint index_size = *index_end;
jint* index_start = (jint*)( (address)index_end - index_size );
tty->print_cr(" index @" INTPTR_FORMAT ": index_size=%d", p2i(index_start), index_size);
if (index_size > 0) {
jint* ip;
for (ip = index_start; ip+2 <= index_end; ip += 2)
tty->print_cr(" (%d %d) addr=" INTPTR_FORMAT " @" INTPTR_FORMAT,
ip[0],
ip[1],
p2i(header_end()+ip[0]),
p2i(relocation_begin()-1+ip[1]));
for (; ip < index_end; ip++)
tty->print_cr(" (%d ?)", ip[0]);
tty->print_cr(" @" INTPTR_FORMAT ": index_size=%d", p2i(ip), *ip);
ip++;
tty->print_cr("reloc_end @" INTPTR_FORMAT ":", p2i(ip));
}
}
}

View File

@ -191,139 +191,18 @@ bool RelocIterator::addr_in_const() const {
}
static inline int num_cards(int code_size) {
return (code_size-1) / indexCardSize;
}
int RelocIterator::locs_and_index_size(int code_size, int locs_size) {
if (!UseRelocIndex) return locs_size; // no index
code_size = round_to(code_size, oopSize);
locs_size = round_to(locs_size, oopSize);
int index_size = num_cards(code_size) * sizeof(RelocIndexEntry);
// format of indexed relocs:
// relocation_begin: relocInfo ...
// index: (addr,reloc#) ...
// indexSize :relocation_end
return locs_size + index_size + BytesPerInt;
}
void RelocIterator::create_index(relocInfo* dest_begin, int dest_count, relocInfo* dest_end) {
address relocation_begin = (address)dest_begin;
address relocation_end = (address)dest_end;
int total_size = relocation_end - relocation_begin;
int locs_size = dest_count * sizeof(relocInfo);
if (!UseRelocIndex) {
Copy::fill_to_bytes(relocation_begin + locs_size, total_size-locs_size, 0);
return;
}
int index_size = total_size - locs_size - BytesPerInt; // find out how much space is left
int ncards = index_size / sizeof(RelocIndexEntry);
assert(total_size == locs_size + index_size + BytesPerInt, "checkin'");
assert(index_size >= 0 && index_size % sizeof(RelocIndexEntry) == 0, "checkin'");
jint* index_size_addr = (jint*)relocation_end - 1;
assert(sizeof(jint) == BytesPerInt, "change this code");
*index_size_addr = index_size;
if (index_size != 0) {
assert(index_size > 0, "checkin'");
RelocIndexEntry* index = (RelocIndexEntry *)(relocation_begin + locs_size);
assert(index == (RelocIndexEntry*)index_size_addr - ncards, "checkin'");
// walk over the relocations, and fill in index entries as we go
RelocIterator iter;
const address initial_addr = NULL;
relocInfo* const initial_current = dest_begin - 1; // biased by -1 like elsewhere
iter._code = NULL;
iter._addr = initial_addr;
iter._limit = (address)(intptr_t)(ncards * indexCardSize);
iter._current = initial_current;
iter._end = dest_begin + dest_count;
int i = 0;
address next_card_addr = (address)indexCardSize;
int addr_offset = 0;
int reloc_offset = 0;
while (true) {
// Checkpoint the iterator before advancing it.
addr_offset = iter._addr - initial_addr;
reloc_offset = iter._current - initial_current;
if (!iter.next()) break;
while (iter.addr() >= next_card_addr) {
index[i].addr_offset = addr_offset;
index[i].reloc_offset = reloc_offset;
i++;
next_card_addr += indexCardSize;
}
}
while (i < ncards) {
index[i].addr_offset = addr_offset;
index[i].reloc_offset = reloc_offset;
i++;
}
}
}
void RelocIterator::set_limits(address begin, address limit) {
int index_size = 0;
if (UseRelocIndex && _code != NULL) {
index_size = ((jint*)_end)[-1];
_end = (relocInfo*)( (address)_end - index_size - BytesPerInt );
}
_limit = limit;
// the limit affects this next stuff:
if (begin != NULL) {
#ifdef ASSERT
// In ASSERT mode we do not actually use the index, but simply
// check that its contents would have led us to the right answer.
address addrCheck = _addr;
relocInfo* infoCheck = _current;
#endif // ASSERT
if (index_size > 0) {
// skip ahead
RelocIndexEntry* index = (RelocIndexEntry*)_end;
RelocIndexEntry* index_limit = (RelocIndexEntry*)((address)index + index_size);
assert(_addr == _code->code_begin(), "_addr must be unadjusted");
int card = (begin - _addr) / indexCardSize;
if (card > 0) {
if (index+card-1 < index_limit) index += card-1;
else index = index_limit - 1;
#ifdef ASSERT
addrCheck = _addr + index->addr_offset;
infoCheck = _current + index->reloc_offset;
#else
// Advance the iterator immediately to the last valid state
// for the previous card. Calling "next" will then advance
// it to the first item on the required card.
_addr += index->addr_offset;
_current += index->reloc_offset;
#endif // ASSERT
}
}
relocInfo* backup;
address backup_addr;
while (true) {
backup = _current;
backup_addr = _addr;
#ifdef ASSERT
if (backup == infoCheck) {
assert(backup_addr == addrCheck, "must match"); addrCheck = NULL; infoCheck = NULL;
} else {
assert(addrCheck == NULL || backup_addr <= addrCheck, "must not pass addrCheck");
}
#endif // ASSERT
if (!next() || addr() >= begin) break;
}
assert(addrCheck == NULL || addrCheck == backup_addr, "must have matched addrCheck");
assert(infoCheck == NULL || infoCheck == backup, "must have matched infoCheck");
// At this point, either we are at the first matching record,
// or else there is no such record, and !has_current().
// In either case, revert to the immediatly preceding state.

View File

@ -628,13 +628,6 @@ class RelocIterator : public StackObj {
// generic relocation accessor; switches on type to call the above
Relocation* reloc();
// CodeBlob's have relocation indexes for faster random access:
static int locs_and_index_size(int code_size, int locs_size);
// Store an index into [dest_start+dest_count..dest_end).
// At dest_start[0..dest_count] is the actual relocation information.
// Everything else up to dest_end is free space for the index.
static void create_index(relocInfo* dest_begin, int dest_count, relocInfo* dest_end);
#ifndef PRODUCT
public:
void print();

View File

@ -2501,9 +2501,6 @@ public:
diagnostic(bool, StressCodeAging, false, \
"Start with counters compiled in") \
\
develop(bool, UseRelocIndex, false, \
"Use an index to speed random access to relocations") \
\
develop(bool, StressCodeBuffers, false, \
"Exercise code buffer expansion and other rare state changes") \
\

View File

@ -773,221 +773,221 @@ public class TestIntUnsafeCAS {
static void test_ci(int[] a) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -1, -123);
unsafe.compareAndSetInt(a, byte_offset(i), -1, -123);
}
}
static void test_vi(int[] a, int b, int old) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
unsafe.compareAndSetInt(a, byte_offset(i), old, b);
}
}
static void test_cp(int[] a, int[] b) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]);
}
}
static void test_2ci(int[] a, int[] b) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
}
}
static void test_2vi(int[] a, int[] b, int c, int d) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i), -103, d);
}
}
static void test_ci_neg(int[] a, int old) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), old, -123);
unsafe.compareAndSetInt(a, byte_offset(i), old, -123);
}
}
static void test_vi_neg(int[] a, int b, int old) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
unsafe.compareAndSetInt(a, byte_offset(i), old, b);
}
}
static void test_cp_neg(int[] a, int[] b) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]);
}
}
static void test_2ci_neg(int[] a, int[] b) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
}
}
static void test_2vi_neg(int[] a, int[] b, int c, int d) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i), -103, d);
}
}
static void test_ci_oppos(int[] a, int old) {
int limit = ARRLEN-1;
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, -123);
unsafe.compareAndSetInt(a, byte_offset(limit-i), old, -123);
}
}
static void test_vi_oppos(int[] a, int b, int old) {
int limit = ARRLEN-1;
for (int i = limit; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, b);
unsafe.compareAndSetInt(a, byte_offset(limit-i), old, b);
}
}
static void test_cp_oppos(int[] a, int[] b) {
int limit = ARRLEN-1;
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[limit-i]);
unsafe.compareAndSetInt(a, byte_offset(i), -123, b[limit-i]);
}
}
static void test_2ci_oppos(int[] a, int[] b) {
int limit = ARRLEN-1;
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(limit-i), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(limit-i), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
}
}
static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
int limit = ARRLEN-1;
for (int i = limit; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(limit-i), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
unsafe.compareAndSetInt(b, byte_offset(limit-i), -103, d);
}
}
static void test_ci_off(int[] a, int old) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, -123);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, -123);
}
}
static void test_vi_off(int[] a, int b, int old) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, b);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, b);
}
}
static void test_cp_off(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
}
}
static void test_2ci_off(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), 123, -103);
}
}
static void test_2vi_off(int[] a, int[] b, int c, int d) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), -103, d);
}
}
static void test_ci_inv(int[] a, int k, int old) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), old, -123);
unsafe.compareAndSetInt(a, byte_offset(i+k), old, -123);
}
}
static void test_vi_inv(int[] a, int b, int k, int old) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), old, b);
unsafe.compareAndSetInt(a, byte_offset(i+k), old, b);
}
}
static void test_cp_inv(int[] a, int[] b, int k) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, b[i+k]);
unsafe.compareAndSetInt(a, byte_offset(i+k), -123, b[i+k]);
}
}
static void test_2ci_inv(int[] a, int[] b, int k) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i+k), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i+k), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i+k), 123, -103);
}
}
static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i+k), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i+k), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i+k), -103, d);
}
}
static void test_ci_scl(int[] a, int old) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, -123);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, -123);
}
}
static void test_vi_scl(int[] a, int b, int old) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, b);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, b);
}
}
static void test_cp_scl(int[] a, int[] b) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
}
}
static void test_2ci_scl(int[] a, int[] b) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i*SCALE), 123, -103);
}
}
static void test_2vi_scl(int[] a, int[] b, int c, int d) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i*SCALE), -103, d);
}
}
static void test_cp_alndst(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
}
}
static void test_cp_alnsrc(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
int old = unsafe.getIntVolatile(a, byte_offset(i));
unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
}
}
static void test_2ci_aln(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
int old = unsafe.getIntVolatile(b, byte_offset(i));
unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
unsafe.compareAndSetInt(b, byte_offset(i), old, -103);
}
}
static void test_2vi_aln(int[] a, int[] b, int c, int d) {
for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
int old = unsafe.getIntVolatile(a, byte_offset(i));
unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
unsafe.compareAndSetInt(a, byte_offset(i), old, c);
old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF));
unsafe.compareAndSwapInt(b, byte_offset(i+ALIGN_OFF), old, d);
unsafe.compareAndSetInt(b, byte_offset(i+ALIGN_OFF), old, d);
}
}
static void test_cp_unalndst(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
}
}
static void test_cp_unalnsrc(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
int old = unsafe.getIntVolatile(a, byte_offset(i));
unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
}
}
static void test_2ci_unaln(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
int old = unsafe.getIntVolatile(b, byte_offset(i));
unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
unsafe.compareAndSetInt(b, byte_offset(i), old, -103);
}
}
static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
int old = unsafe.getIntVolatile(a, byte_offset(i));
unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
unsafe.compareAndSetInt(a, byte_offset(i), old, c);
old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF));
unsafe.compareAndSwapInt(b, byte_offset(i+UNALIGN_OFF), old, d);
unsafe.compareAndSetInt(b, byte_offset(i+UNALIGN_OFF), old, d);
}
}

View File

@ -64,7 +64,7 @@ public class UnsafeAccess {
static Object helperUnsafeLoadStore(Object o, boolean isObjArray) {
if (isObjArray) {
Object o1 = U.getObject(o, off);
U.compareAndSwapObject(o, off, o1, new Object());
U.compareAndSetObject(o, off, o1, new Object());
}
return o;
}