mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8033528: assert(0 <= i && i < length()) failed: index out of bounds
Restoring bytecodes for invokedynamic had wrong index calculation added testing stress option. Reviewed-by: twisti, hseigel
This commit is contained in:
parent
3d76a6654e
commit
2759eb10ae
6 changed files with 43 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -250,8 +250,8 @@ void Rewriter::rewrite_invokedynamic(address bcp, int offset, bool reverse) {
|
||||||
// We will reverse the bytecode rewriting _after_ adjusting them.
|
// We will reverse the bytecode rewriting _after_ adjusting them.
|
||||||
// Adjust the cache index by offset to the invokedynamic entries in the
|
// Adjust the cache index by offset to the invokedynamic entries in the
|
||||||
// cpCache plus the delta if the invokedynamic bytecodes were adjusted.
|
// cpCache plus the delta if the invokedynamic bytecodes were adjusted.
|
||||||
cache_index = cp_cache_delta() + _first_iteration_cp_cache_limit;
|
int adjustment = cp_cache_delta() + _first_iteration_cp_cache_limit;
|
||||||
int cp_index = invokedynamic_cp_cache_entry_pool_index(cache_index);
|
int cp_index = invokedynamic_cp_cache_entry_pool_index(cache_index - adjustment);
|
||||||
assert(_pool->tag_at(cp_index).is_invoke_dynamic(), "wrong index");
|
assert(_pool->tag_at(cp_index).is_invoke_dynamic(), "wrong index");
|
||||||
// zero out 4 bytes
|
// zero out 4 bytes
|
||||||
Bytes::put_Java_u4(p, 0);
|
Bytes::put_Java_u4(p, 0);
|
||||||
|
@ -453,18 +453,7 @@ methodHandle Rewriter::rewrite_jsrs(methodHandle method, TRAPS) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) {
|
void Rewriter::rewrite_bytecodes(TRAPS) {
|
||||||
ResourceMark rm(THREAD);
|
|
||||||
Rewriter rw(klass, klass->constants(), klass->methods(), CHECK);
|
|
||||||
// (That's all, folks.)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Rewriter::Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, Array<Method*>* methods, TRAPS)
|
|
||||||
: _klass(klass),
|
|
||||||
_pool(cpool),
|
|
||||||
_methods(methods)
|
|
||||||
{
|
|
||||||
assert(_pool->cache() == NULL, "constant pool cache must not be set yet");
|
assert(_pool->cache() == NULL, "constant pool cache must not be set yet");
|
||||||
|
|
||||||
// determine index maps for Method* rewriting
|
// determine index maps for Method* rewriting
|
||||||
|
@ -508,6 +497,29 @@ Rewriter::Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, Array<Me
|
||||||
// May have to fix invokedynamic bytecodes if invokestatic/InterfaceMethodref
|
// May have to fix invokedynamic bytecodes if invokestatic/InterfaceMethodref
|
||||||
// entries had to be added.
|
// entries had to be added.
|
||||||
patch_invokedynamic_bytecodes();
|
patch_invokedynamic_bytecodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) {
|
||||||
|
ResourceMark rm(THREAD);
|
||||||
|
Rewriter rw(klass, klass->constants(), klass->methods(), CHECK);
|
||||||
|
// (That's all, folks.)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Rewriter::Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, Array<Method*>* methods, TRAPS)
|
||||||
|
: _klass(klass),
|
||||||
|
_pool(cpool),
|
||||||
|
_methods(methods)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Rewrite bytecodes - exception here exits.
|
||||||
|
rewrite_bytecodes(CHECK);
|
||||||
|
|
||||||
|
// Stress restoring bytecodes
|
||||||
|
if (StressRewriter) {
|
||||||
|
restore_bytecodes();
|
||||||
|
rewrite_bytecodes(CHECK);
|
||||||
|
}
|
||||||
|
|
||||||
// allocate constant pool cache, now that we've seen all the bytecodes
|
// allocate constant pool cache, now that we've seen all the bytecodes
|
||||||
make_constant_pool_cache(THREAD);
|
make_constant_pool_cache(THREAD);
|
||||||
|
@ -523,6 +535,7 @@ Rewriter::Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, Array<Me
|
||||||
// so methods with jsrs in custom class lists in aren't attempted to be
|
// so methods with jsrs in custom class lists in aren't attempted to be
|
||||||
// rewritten in the RO section of the shared archive.
|
// rewritten in the RO section of the shared archive.
|
||||||
// Relocated bytecodes don't have to be restored, only the cp cache entries
|
// Relocated bytecodes don't have to be restored, only the cp cache entries
|
||||||
|
int len = _methods->length();
|
||||||
for (int i = len-1; i >= 0; i--) {
|
for (int i = len-1; i >= 0; i--) {
|
||||||
methodHandle m(THREAD, _methods->at(i));
|
methodHandle m(THREAD, _methods->at(i));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -199,6 +199,9 @@ class Rewriter: public StackObj {
|
||||||
|
|
||||||
void patch_invokedynamic_bytecodes();
|
void patch_invokedynamic_bytecodes();
|
||||||
|
|
||||||
|
// Do all the work.
|
||||||
|
void rewrite_bytecodes(TRAPS);
|
||||||
|
|
||||||
// Revert bytecodes in case of an exception.
|
// Revert bytecodes in case of an exception.
|
||||||
void restore_bytecodes();
|
void restore_bytecodes();
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,9 @@ ConstantPool::ConstantPool(Array<u1>* tags) {
|
||||||
void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) {
|
void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) {
|
||||||
MetadataFactory::free_metadata(loader_data, cache());
|
MetadataFactory::free_metadata(loader_data, cache());
|
||||||
set_cache(NULL);
|
set_cache(NULL);
|
||||||
|
MetadataFactory::free_array<u2>(loader_data, reference_map());
|
||||||
|
set_reference_map(NULL);
|
||||||
|
|
||||||
MetadataFactory::free_array<jushort>(loader_data, operands());
|
MetadataFactory::free_array<jushort>(loader_data, operands());
|
||||||
set_operands(NULL);
|
set_operands(NULL);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -1260,6 +1260,9 @@ class CommandLineFlags {
|
||||||
develop(bool, TraceJNICalls, false, \
|
develop(bool, TraceJNICalls, false, \
|
||||||
"Trace JNI calls") \
|
"Trace JNI calls") \
|
||||||
\
|
\
|
||||||
|
develop(bool, StressRewriter, false, \
|
||||||
|
"Stress linktime bytecode rewriting") \
|
||||||
|
\
|
||||||
notproduct(bool, TraceJVMCalls, false, \
|
notproduct(bool, TraceJVMCalls, false, \
|
||||||
"Trace JVM calls") \
|
"Trace JVM calls") \
|
||||||
\
|
\
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -58,7 +58,7 @@ class ResourceArray: public ResourceObj {
|
||||||
|
|
||||||
void initialize(size_t esize, int length) {
|
void initialize(size_t esize, int length) {
|
||||||
assert(length >= 0, "illegal length");
|
assert(length >= 0, "illegal length");
|
||||||
assert(_data == NULL, "must be new object");
|
assert(StressRewriter || _data == NULL, "must be new object");
|
||||||
_length = length;
|
_length = length;
|
||||||
_data = resource_allocate_bytes(esize * length);
|
_data = resource_allocate_bytes(esize * length);
|
||||||
DEBUG_ONLY(init_nesting();)
|
DEBUG_ONLY(init_nesting();)
|
||||||
|
|
|
@ -26,8 +26,9 @@
|
||||||
* @test
|
* @test
|
||||||
* @bug 8032024
|
* @bug 8032024
|
||||||
* @bug 8025937
|
* @bug 8025937
|
||||||
|
* @bug 8033528
|
||||||
* @summary [JDK 8] Test invokespecial and invokeinterface with the same JVM_CONSTANT_InterfaceMethodref
|
* @summary [JDK 8] Test invokespecial and invokeinterface with the same JVM_CONSTANT_InterfaceMethodref
|
||||||
* @run main InvokespecialInterface
|
* @run main/othervm -XX:+StressRewriter InvokespecialInterface
|
||||||
*/
|
*/
|
||||||
import java.util.function.*;
|
import java.util.function.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue