This commit is contained in:
Jesper Wilhelmsson 2019-01-14 23:05:26 +01:00
commit 528bc73ca4
51 changed files with 355 additions and 233 deletions

View file

@ -269,7 +269,7 @@ class StubGenerator: public StubCodeGenerator {
// when called via a c2i. // when called via a c2i.
// Pass initial_caller_sp to framemanager. // Pass initial_caller_sp to framemanager.
__ mr(R21_tmp1, R1_SP); __ mr(R21_sender_SP, R1_SP);
// Do a light-weight C-call here, r_new_arg_entry holds the address // Do a light-weight C-call here, r_new_arg_entry holds the address
// of the interpreter entry point (frame manager or native entry) // of the interpreter entry point (frame manager or native entry)

View file

@ -532,14 +532,8 @@ address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {
// these parameters the pre-barrier does not generate // these parameters the pre-barrier does not generate
// the load of the previous value. // the load of the previous value.
// Restore caller sp for c2i case. // Restore caller sp for c2i case (from compiled) and for resized sender frame (from interpreted).
#ifdef ASSERT __ resize_frame_absolute(R21_sender_SP, R11_scratch1, R0);
__ ld(R9_ARG7, 0, R1_SP);
__ ld(R10_ARG8, 0, R21_sender_SP);
__ cmpd(CCR0, R9_ARG7, R10_ARG8);
__ asm_assert_eq("backlink", 0x544);
#endif // ASSERT
__ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
__ blr(); __ blr();
@ -835,8 +829,13 @@ void TemplateInterpreterGenerator::generate_stack_overflow_check(Register Rmem_f
assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "generated in wrong order"); assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "generated in wrong order");
__ load_const_optimized(Rscratch1, (StubRoutines::throw_StackOverflowError_entry()), R0); __ load_const_optimized(Rscratch1, (StubRoutines::throw_StackOverflowError_entry()), R0);
__ mtctr(Rscratch1); __ mtctr(Rscratch1);
// Restore caller_sp. // Restore caller_sp (c2i adapter may exist, but no shrinking of interpreted caller frame).
#ifdef ASSERT #ifdef ASSERT
Label frame_not_shrunk;
__ cmpld(CCR0, R1_SP, R21_sender_SP);
__ ble(CCR0, frame_not_shrunk);
__ stop("frame shrunk", 0x546);
__ bind(frame_not_shrunk);
__ ld(Rscratch1, 0, R1_SP); __ ld(Rscratch1, 0, R1_SP);
__ ld(R0, 0, R21_sender_SP); __ ld(R0, 0, R21_sender_SP);
__ cmpd(CCR0, R0, Rscratch1); __ cmpd(CCR0, R0, Rscratch1);
@ -1155,15 +1154,6 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M
} }
} }
// Pop c2i arguments (if any) off when we return.
#ifdef ASSERT
__ ld(R9_ARG7, 0, R1_SP);
__ ld(R10_ARG8, 0, R21_sender_SP);
__ cmpd(CCR0, R9_ARG7, R10_ARG8);
__ asm_assert_eq("backlink", 0x545);
#endif // ASSERT
__ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
if (use_instruction) { if (use_instruction) {
switch (kind) { switch (kind) {
case Interpreter::java_lang_math_sqrt: __ fsqrt(F1_RET, F1); break; case Interpreter::java_lang_math_sqrt: __ fsqrt(F1_RET, F1); break;
@ -1188,6 +1178,8 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M
__ restore_LR_CR(R0); __ restore_LR_CR(R0);
} }
// Restore caller sp for c2i case (from compiled) and for resized sender frame (from interpreted).
__ resize_frame_absolute(R21_sender_SP, R11_scratch1, R0);
__ blr(); __ blr();
__ flush(); __ flush();
@ -1843,8 +1835,8 @@ address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table); StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
__ kernel_crc32_singleByte(crc, data, dataLen, table, tmp, true); __ kernel_crc32_singleByte(crc, data, dataLen, table, tmp, true);
// Restore caller sp for c2i case and return. // Restore caller sp for c2i case (from compiled) and for resized sender frame (from interpreted).
__ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started. __ resize_frame_absolute(R21_sender_SP, R11_scratch1, R0);
__ blr(); __ blr();
// Generate a vanilla native entry as the slow path. // Generate a vanilla native entry as the slow path.
@ -1931,8 +1923,8 @@ address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractI
// code compactness. // code compactness.
__ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, true); __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, true);
// Restore caller sp for c2i case and return. // Restore caller sp for c2i case (from compiled) and for resized sender frame (from interpreted).
__ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started. __ resize_frame_absolute(R21_sender_SP, R11_scratch1, R0);
__ blr(); __ blr();
// Generate a vanilla native entry as the slow path. // Generate a vanilla native entry as the slow path.
@ -2019,8 +2011,8 @@ address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(Abstract
// code compactness. // code compactness.
__ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, false); __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, false);
// Restore caller sp for c2i case and return. // Restore caller sp for c2i case (from compiled) and for resized sender frame (from interpreted).
__ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started. __ resize_frame_absolute(R21_sender_SP, R11_scratch1, R0);
__ blr(); __ blr();
BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}"); BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}");

View file

@ -46,6 +46,7 @@ class ciEnv : StackObj {
friend class CompileBroker; friend class CompileBroker;
friend class Dependencies; // for get_object, during logging friend class Dependencies; // for get_object, during logging
friend class PrepareExtraDataClosure;
private: private:
Arena* _arena; // Alias for _ciEnv_arena except in init_shared_objects() Arena* _arena; // Alias for _ciEnv_arena except in init_shared_objects()
@ -188,6 +189,10 @@ private:
} }
} }
ciMetadata* cached_metadata(Metadata* o) {
return _factory->cached_metadata(o);
}
ciInstance* get_instance(oop o) { ciInstance* get_instance(oop o) {
if (o == NULL) return NULL; if (o == NULL) return NULL;
return get_object(o)->as_instance(); return get_object(o)->as_instance();

View file

@ -78,10 +78,81 @@ ciMethodData::ciMethodData() : ciMetadata(NULL) {
_parameters = NULL; _parameters = NULL;
} }
void ciMethodData::load_extra_data() { // Check for entries that reference an unloaded method
class PrepareExtraDataClosure : public CleanExtraDataClosure {
MethodData* _mdo;
uint64_t _safepoint_counter;
GrowableArray<Method*> _uncached_methods;
public:
PrepareExtraDataClosure(MethodData* mdo)
: _mdo(mdo),
_safepoint_counter(SafepointSynchronize::safepoint_counter()),
_uncached_methods()
{ }
bool is_live(Method* m) {
if (!m->method_holder()->is_loader_alive()) {
return false;
}
if (CURRENT_ENV->cached_metadata(m) == NULL) {
// Uncached entries need to be pre-populated.
_uncached_methods.append(m);
}
return true;
}
bool has_safepointed() {
return SafepointSynchronize::safepoint_counter() != _safepoint_counter;
}
bool finish() {
if (_uncached_methods.length() == 0) {
// Preparation finished iff all Methods* were already cached.
return true;
}
// Holding locks through safepoints is bad practice.
MutexUnlocker mu(_mdo->extra_data_lock());
for (int i = 0; i < _uncached_methods.length(); ++i) {
if (has_safepointed()) {
// The metadata in the growable array might contain stale
// entries after a safepoint.
return false;
}
Method* method = _uncached_methods.at(i);
// Populating ciEnv caches may cause safepoints due
// to taking the Compile_lock with safepoint checks.
(void)CURRENT_ENV->get_method(method);
}
return false;
}
};
void ciMethodData::prepare_metadata() {
MethodData* mdo = get_MethodData(); MethodData* mdo = get_MethodData();
for (;;) {
ResourceMark rm;
PrepareExtraDataClosure cl(mdo);
mdo->clean_extra_data(&cl);
if (cl.finish()) {
// When encountering uncached metadata, the Compile_lock might be
// acquired when creating ciMetadata handles, causing safepoints
// which requires a new round of preparation to clean out potentially
// new unloading metadata.
return;
}
}
}
void ciMethodData::load_extra_data() {
MethodData* mdo = get_MethodData();
MutexLocker ml(mdo->extra_data_lock()); MutexLocker ml(mdo->extra_data_lock());
// Deferred metadata cleaning due to concurrent class unloading.
prepare_metadata();
// After metadata preparation, there is no stale metadata,
// and no safepoints can introduce more stale metadata.
NoSafepointVerifier no_safepoint;
// speculative trap entries also hold a pointer to a Method so need to be translated // speculative trap entries also hold a pointer to a Method so need to be translated
DataLayout* dp_src = mdo->extra_data_base(); DataLayout* dp_src = mdo->extra_data_base();
@ -94,7 +165,7 @@ void ciMethodData::load_extra_data() {
// New traps in the MDO may have been added since we copied the // New traps in the MDO may have been added since we copied the
// data (concurrent deoptimizations before we acquired // data (concurrent deoptimizations before we acquired
// extra_data_lock above) or can be removed (a safepoint may occur // extra_data_lock above) or can be removed (a safepoint may occur
// in the translate_from call below) as we translate the copy: // in the prepare_metadata call above) as we translate the copy:
// update the copy as we go. // update the copy as we go.
int tag = dp_src->tag(); int tag = dp_src->tag();
if (tag != DataLayout::arg_info_data_tag) { if (tag != DataLayout::arg_info_data_tag) {
@ -105,11 +176,7 @@ void ciMethodData::load_extra_data() {
case DataLayout::speculative_trap_data_tag: { case DataLayout::speculative_trap_data_tag: {
ciSpeculativeTrapData data_dst(dp_dst); ciSpeculativeTrapData data_dst(dp_dst);
SpeculativeTrapData data_src(dp_src); SpeculativeTrapData data_src(dp_src);
data_dst.translate_from(&data_src);
{ // During translation a safepoint can happen or VM lock can be taken (e.g., Compile_lock).
MutexUnlocker ml(mdo->extra_data_lock());
data_dst.translate_from(&data_src);
}
break; break;
} }
case DataLayout::bit_data_tag: case DataLayout::bit_data_tag:

View file

@ -475,6 +475,7 @@ private:
return (address) _data; return (address) _data;
} }
void prepare_metadata();
void load_extra_data(); void load_extra_data();
ciProfileData* bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots); ciProfileData* bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots);

View file

@ -265,6 +265,24 @@ int ciObjectFactory::metadata_compare(Metadata* const& key, ciMetadata* const& e
else return 0; else return 0;
} }
// ------------------------------------------------------------------
// ciObjectFactory::cached_metadata
//
// Get the ciMetadata corresponding to some Metadata. If the ciMetadata has
// already been created, it is returned. Otherwise, null is returned.
ciMetadata* ciObjectFactory::cached_metadata(Metadata* key) {
ASSERT_IN_VM;
bool found = false;
int index = _ci_metadata->find_sorted<Metadata*, ciObjectFactory::metadata_compare>(key, found);
if (!found) {
return NULL;
}
return _ci_metadata->at(index)->as_metadata();
}
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// ciObjectFactory::get_metadata // ciObjectFactory::get_metadata
// //

View file

@ -100,6 +100,7 @@ public:
// Get the ciObject corresponding to some oop. // Get the ciObject corresponding to some oop.
ciObject* get(oop key); ciObject* get(oop key);
ciMetadata* get_metadata(Metadata* key); ciMetadata* get_metadata(Metadata* key);
ciMetadata* cached_metadata(Metadata* key);
ciSymbol* get_symbol(Symbol* key); ciSymbol* get_symbol(Symbol* key);
// Get the ciSymbol corresponding to one of the vmSymbols. // Get the ciSymbol corresponding to one of the vmSymbols.

View file

@ -1159,6 +1159,19 @@ void nmethod::log_state_change() const {
} }
} }
void nmethod::unlink_from_method(bool acquire_lock) {
// We need to check if both the _code and _from_compiled_code_entry_point
// refer to this nmethod because there is a race in setting these two fields
// in Method* as seen in bugid 4947125.
// If the vep() points to the zombie nmethod, the memory for the nmethod
// could be flushed and the compiler and vtable stubs could still call
// through it.
if (method() != NULL && (method()->code() == this ||
method()->from_compiled_entry() == verified_entry_point())) {
method()->clear_code(acquire_lock);
}
}
/** /**
* Common functionality for both make_not_entrant and make_zombie * Common functionality for both make_not_entrant and make_zombie
*/ */
@ -1246,17 +1259,7 @@ bool nmethod::make_not_entrant_or_zombie(int state) {
JVMCI_ONLY(maybe_invalidate_installed_code()); JVMCI_ONLY(maybe_invalidate_installed_code());
// Remove nmethod from method. // Remove nmethod from method.
// We need to check if both the _code and _from_compiled_code_entry_point unlink_from_method(false /* already owns Patching_lock */);
// refer to this nmethod because there is a race in setting these two fields
// in Method* as seen in bugid 4947125.
// If the vep() points to the zombie nmethod, the memory for the nmethod
// could be flushed and the compiler and vtable stubs could still call
// through it.
if (method() != NULL && (method()->code() == this ||
method()->from_compiled_entry() == verified_entry_point())) {
HandleMark hm;
method()->clear_code(false /* already owns Patching_lock */);
}
} // leave critical region under Patching_lock } // leave critical region under Patching_lock
#ifdef ASSERT #ifdef ASSERT

View file

@ -377,6 +377,8 @@ class nmethod : public CompiledMethod {
int comp_level() const { return _comp_level; } int comp_level() const { return _comp_level; }
void unlink_from_method(bool acquire_lock);
// Support for oops in scopes and relocs: // Support for oops in scopes and relocs:
// Note: index 0 is reserved for null. // Note: index 0 is reserved for null.
oop oop_at(int index) const; oop oop_at(int index) const;

View file

@ -42,6 +42,11 @@ bool ZBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
} }
if (nm->is_unloading()) { if (nm->is_unloading()) {
// We don't need to take the lock when unlinking nmethods from
// the Method, because it is only concurrently unlinked by
// the entry barrier, which acquires the per nmethod lock.
nm->unlink_from_method(false /* acquire_lock */);
// We can end up calling nmethods that are unloading // We can end up calling nmethods that are unloading
// since we clear compiled ICs lazily. Returning false // since we clear compiled ICs lazily. Returning false
// will re-resovle the call and update the compiled IC. // will re-resovle the call and update the compiled IC.

View file

@ -611,15 +611,20 @@ public:
return; return;
} }
ZLocker<ZReentrantLock> locker(ZNMethodTable::lock_for_nmethod(nm));
if (nm->is_unloading()) { if (nm->is_unloading()) {
// Unlinking of the dependencies must happen before the // Unlinking of the dependencies must happen before the
// handshake separating unlink and purge. // handshake separating unlink and purge.
nm->flush_dependencies(false /* delete_immediately */); nm->flush_dependencies(false /* delete_immediately */);
// We don't need to take the lock when unlinking nmethods from
// the Method, because it is only concurrently unlinked by
// the entry barrier, which acquires the per nmethod lock.
nm->unlink_from_method(false /* acquire_lock */);
return; return;
} }
ZLocker<ZReentrantLock> locker(ZNMethodTable::lock_for_nmethod(nm));
// Heal oops and disarm // Heal oops and disarm
ZNMethodOopClosure cl; ZNMethodOopClosure cl;
ZNMethodTable::entry_oops_do(entry, &cl); ZNMethodTable::entry_oops_do(entry, &cl);

View file

@ -2178,6 +2178,7 @@ void InstanceKlass::clean_method_data() {
for (int m = 0; m < methods()->length(); m++) { for (int m = 0; m < methods()->length(); m++) {
MethodData* mdo = methods()->at(m)->method_data(); MethodData* mdo = methods()->at(m)->method_data();
if (mdo != NULL) { if (mdo != NULL) {
MutexLockerEx ml(SafepointSynchronize::is_at_safepoint() ? NULL : mdo->extra_data_lock());
mdo->clean_method_data(/*always_clean*/false); mdo->clean_method_data(/*always_clean*/false);
} }
} }

View file

@ -1653,11 +1653,6 @@ void MethodData::clean_extra_data_helper(DataLayout* dp, int shift, bool reset)
} }
} }
class CleanExtraDataClosure : public StackObj {
public:
virtual bool is_live(Method* m) = 0;
};
// Check for entries that reference an unloaded method // Check for entries that reference an unloaded method
class CleanExtraDataKlassClosure : public CleanExtraDataClosure { class CleanExtraDataKlassClosure : public CleanExtraDataClosure {
bool _always_clean; bool _always_clean;

View file

@ -1943,7 +1943,11 @@ public:
// adjusted in the event of a change in control flow. // adjusted in the event of a change in control flow.
// //
class CleanExtraDataClosure; class CleanExtraDataClosure : public StackObj {
public:
virtual bool is_live(Method* m) = 0;
};
class MethodData : public Metadata { class MethodData : public Metadata {
friend class VMStructs; friend class VMStructs;
@ -2116,11 +2120,12 @@ private:
static bool profile_parameters_jsr292_only(); static bool profile_parameters_jsr292_only();
static bool profile_all_parameters(); static bool profile_all_parameters();
void clean_extra_data(CleanExtraDataClosure* cl);
void clean_extra_data_helper(DataLayout* dp, int shift, bool reset = false); void clean_extra_data_helper(DataLayout* dp, int shift, bool reset = false);
void verify_extra_data_clean(CleanExtraDataClosure* cl); void verify_extra_data_clean(CleanExtraDataClosure* cl);
public: public:
void clean_extra_data(CleanExtraDataClosure* cl);
static int header_size() { static int header_size() {
return sizeof(MethodData)/wordSize; return sizeof(MethodData)/wordSize;
} }

View file

@ -1727,7 +1727,8 @@ void ConnectionGraph::adjust_scalar_replaceable_state(JavaObjectNode* jobj) {
// //
Node* n = field->ideal_node(); Node* n = field->ideal_node();
for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
if (n->fast_out(i)->is_LoadStore()) { Node* u = n->fast_out(i);
if (u->is_LoadStore() || (u->is_Mem() && u->as_Mem()->is_mismatched_access())) {
jobj->set_scalar_replaceable(false); jobj->set_scalar_replaceable(false);
return; return;
} }

View file

@ -3419,8 +3419,8 @@ public final class Class<T> implements java.io.Serializable,
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(getName() + "." + name + "("); sb.append(getName() + "." + name + "(");
if (argTypes != null) { if (argTypes != null) {
Stream.of(argTypes).map(c -> {return (c == null) ? "null" : c.getName();}). sb.append(Stream.of(argTypes).map(c -> {return (c == null) ? "null" : c.getName();}).
collect(Collectors.joining(",")); collect(Collectors.joining(",")));
} }
sb.append(")"); sb.append(")");
return sb.toString(); return sb.toString();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2019, 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
@ -1864,35 +1864,6 @@ public abstract class VarHandle implements Constable {
} }
} }
/**
* Compare this {@linkplain VarHandle} with another object for equality.
* Two {@linkplain VarHandle}s are considered equal if they both describe the
* same instance field, both describe the same static field, both describe
* array elements for arrays with the same component type, or both describe
* the same component of an off-heap structure.
*
* @param o the other object
* @return Whether this {@linkplain VarHandle} is equal to the other object
*/
@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VarHandle that = (VarHandle) o;
return accessModeType(AccessMode.GET).equals(that.accessModeType(AccessMode.GET)) &&
internalEquals(that);
}
abstract boolean internalEquals(VarHandle vh);
@Override
public final int hashCode() {
return 31 * accessModeType(AccessMode.GET).hashCode() + internalHashCode();
}
abstract int internalHashCode();
/** /**
* Returns a compact textual description of this {@linkplain VarHandle}, * Returns a compact textual description of this {@linkplain VarHandle},
* including the type of variable described, and a description of its coordinates. * including the type of variable described, and a description of its coordinates.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -63,17 +63,6 @@ final class VarHandle$Type$s {
return accessMode.at.accessModeType(receiverType, {#if[Object]?fieldType:$type$.class}); return accessMode.at.accessModeType(receiverType, {#if[Object]?fieldType:$type$.class});
} }
@Override
final boolean internalEquals(VarHandle vh) {
FieldInstanceReadOnly that = (FieldInstanceReadOnly) vh;
return fieldOffset == that.fieldOffset;
}
@Override
final int internalHashCode() {
return Long.hashCode(fieldOffset);
}
@Override @Override
public Optional<VarHandleDesc> describeConstable() { public Optional<VarHandleDesc> describeConstable() {
var receiverTypeRef = receiverType.describeConstable(); var receiverTypeRef = receiverType.describeConstable();
@ -349,17 +338,6 @@ final class VarHandle$Type$s {
#end[Object] #end[Object]
} }
@Override
final boolean internalEquals(VarHandle vh) {
FieldStaticReadOnly that = (FieldStaticReadOnly) vh;
return base == that.base && fieldOffset == that.fieldOffset;
}
@Override
final int internalHashCode() {
return 31 * Long.hashCode(fieldOffset) + base.hashCode();
}
@Override @Override
public Optional<VarHandleDesc> describeConstable() { public Optional<VarHandleDesc> describeConstable() {
var fieldTypeRef = {#if[Object]?fieldType:$type$.class}.describeConstable(); var fieldTypeRef = {#if[Object]?fieldType:$type$.class}.describeConstable();
@ -639,20 +617,6 @@ final class VarHandle$Type$s {
#end[Object] #end[Object]
} }
@Override
final boolean internalEquals(VarHandle vh) {
// Equality of access mode types of AccessMode.GET is sufficient for
// equality checks
return true;
}
@Override
final int internalHashCode() {
// The hash code of the access mode types of AccessMode.GET is
// sufficient for hash code generation
return 0;
}
@Override @Override
public Optional<VarHandleDesc> describeConstable() { public Optional<VarHandleDesc> describeConstable() {
var arrayTypeRef = {#if[Object]?arrayType:$type$[].class}.describeConstable(); var arrayTypeRef = {#if[Object]?arrayType:$type$[].class}.describeConstable();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -67,17 +67,6 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
super(form); super(form);
this.be = be; this.be = be;
} }
@Override
final boolean internalEquals(VarHandle vh) {
ByteArrayViewVarHandle that = (ByteArrayViewVarHandle) vh;
return be == that.be;
}
@Override
final int internalHashCode() {
return Boolean.hashCode(be);
}
} }
static final class ArrayHandle extends ByteArrayViewVarHandle { static final class ArrayHandle extends ByteArrayViewVarHandle {

View file

@ -31,8 +31,6 @@ import javax.net.ssl.SSLEngineResult.HandshakeStatus;
* Ciphertext * Ciphertext
*/ */
final class Ciphertext { final class Ciphertext {
static final Ciphertext CIPHERTEXT_NULL = new Ciphertext();
final byte contentType; final byte contentType;
final byte handshakeType; final byte handshakeType;
final long recordSN; final long recordSN;

View file

@ -247,6 +247,19 @@ final class SSLEngineImpl extends SSLEngine implements SSLTransport {
hsStatus = ciphertext.handshakeStatus; hsStatus = ciphertext.handshakeStatus;
} else { } else {
hsStatus = getHandshakeStatus(); hsStatus = getHandshakeStatus();
if (ciphertext == null && !conContext.isNegotiated &&
conContext.isInboundClosed() &&
hsStatus == HandshakeStatus.NEED_WRAP) {
// Even the outboud is open, no futher data could be wrapped as:
// 1. the outbound is empty
// 2. no negotiated connection
// 3. the inbound has closed, cannot complete the handshake
//
// Mark the engine as closed if the handshake status is
// NEED_WRAP. Otherwise, it could lead to dead loops in
// applications.
status = Status.CLOSED;
}
} }
int deltaSrcs = srcsRemains; int deltaSrcs = srcsRemains;
@ -279,7 +292,7 @@ final class SSLEngineImpl extends SSLEngine implements SSLTransport {
} }
if (ciphertext == null) { if (ciphertext == null) {
return Ciphertext.CIPHERTEXT_NULL; return null;
} }
// Is the handshake completed? // Is the handshake completed?

View file

@ -577,13 +577,7 @@ class TransportContext implements ConnectionContext {
} else if (!isOutboundClosed()) { } else if (!isOutboundClosed()) {
// Special case that the inbound was closed, but outbound open. // Special case that the inbound was closed, but outbound open.
return HandshakeStatus.NEED_WRAP; return HandshakeStatus.NEED_WRAP;
} } // Otherwise, both inbound and outbound are closed.
} else if (isOutboundClosed() && !isInboundClosed()) {
// Special case that the outbound was closed, but inbound open.
return HandshakeStatus.NEED_UNWRAP;
} else if (!isOutboundClosed() && isInboundClosed()) {
// Special case that the inbound was closed, but outbound open.
return HandshakeStatus.NEED_WRAP;
} }
return HandshakeStatus.NOT_HANDSHAKING; return HandshakeStatus.NOT_HANDSHAKING;

View file

@ -158,10 +158,14 @@ grant codeBase "jrt:/jdk.internal.vm.compiler" {
}; };
grant codeBase "jrt:/jdk.internal.vm.compiler.management" { grant codeBase "jrt:/jdk.internal.vm.compiler.management" {
permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.hotspot"; permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.vm.compiler.collections";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.vm.ci.runtime"; permission java.lang.RuntimePermission "accessClassInPackage.jdk.vm.ci.runtime";
permission java.lang.RuntimePermission "accessClassInPackage.sun.management.spi"; permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.core.common";
permission java.lang.RuntimePermission "sun.management.spi.PlatformMBeanProvider.subclass"; permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.debug";
permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.hotspot";
permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.options";
permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.phases.common.jmx";
permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.serviceprovider";
}; };
grant codeBase "jrt:/jdk.jsobject" { grant codeBase "jrt:/jdk.jsobject" {

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1999, 2019, 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
@ -44,7 +44,7 @@ javac.opt.modulepath=\
javac.opt.sourcepath=\ javac.opt.sourcepath=\
Specify where to find input source files Specify where to find input source files
javac.opt.m=\ javac.opt.m=\
Compile only the specified module, check timestamps Compile only the specified module(s), check timestamps
javac.opt.modulesourcepath=\ javac.opt.modulesourcepath=\
Specify where to find input source files for multiple modules Specify where to find input source files for multiple modules
javac.opt.bootclasspath=\ javac.opt.bootclasspath=\
@ -108,7 +108,7 @@ javac.opt.arg.path=\
javac.opt.arg.mspath=\ javac.opt.arg.mspath=\
<module-source-path> <module-source-path>
javac.opt.arg.m=\ javac.opt.arg.m=\
<module-name> <module>(,<module>)*
javac.opt.arg.jdk=\ javac.opt.arg.jdk=\
<jdk>|none <jdk>|none
javac.opt.arg.dirs=\ javac.opt.arg.dirs=\

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2019, 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
@ -1759,6 +1759,14 @@ public class AMD64Assembler extends AMD64BaseAssembler {
emitOperandHelper(dst, src, 0); emitOperandHelper(dst, src, 0);
} }
public final void cmpb(Register dst, Register src) {
CMP.byteRmOp.emit(this, BYTE, dst, src);
}
public final void cmpw(Register dst, Register src) {
CMP.rmOp.emit(this, WORD, dst, src);
}
public final void cmpl(Register dst, int imm32) { public final void cmpl(Register dst, int imm32) {
CMP.getMIOpcode(DWORD, isByte(imm32)).emit(this, DWORD, dst, imm32); CMP.getMIOpcode(DWORD, isByte(imm32)).emit(this, DWORD, dst, imm32);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019 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
@ -125,6 +125,14 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
return kind == JavaKind.Char; return kind == JavaKind.Char;
} }
private JavaKind getComparisonKind() {
return findTwoConsecutive ? (byteMode(kind) ? JavaKind.Char : JavaKind.Int) : kind;
}
private AVXKind.AVXSize getVectorSize() {
return AVXKind.getDataSize(vectorKind);
}
@Override @Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) { public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) {
Register arrayPtr = asRegister(arrayPtrValue); Register arrayPtr = asRegister(arrayPtrValue);
@ -159,9 +167,6 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
Label retNotFound = new Label(); Label retNotFound = new Label();
Label end = new Label(); Label end = new Label();
AVXKind.AVXSize vectorSize = AVXKind.getDataSize(vectorKind);
int nVectors = nValues == 1 ? 4 : nValues == 2 ? 2 : 1;
// load array length // load array length
// important: this must be the first register manipulation, since arrayLengthValue is // important: this must be the first register manipulation, since arrayLengthValue is
// annotated with @Use // annotated with @Use
@ -178,10 +183,10 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
} }
// fill comparison vector with copies of the search value // fill comparison vector with copies of the search value
for (int i = 0; i < nValues; i++) { for (int i = 0; i < nValues; i++) {
emitBroadcast(asm, findTwoConsecutive ? (byteMode(kind) ? JavaKind.Char : JavaKind.Int) : kind, vecCmp[i], vecArray[0], vectorSize); emitBroadcast(asm, getComparisonKind(), vecCmp[i], vecArray[0], getVectorSize());
} }
emitArrayIndexOfChars(crb, asm, kind, vectorSize, result, slotsRemaining, searchValue, vecCmp, vecArray, cmpResult, retFound, retNotFound, vmPageSize, nValues, nVectors, findTwoConsecutive); emitArrayIndexOfChars(crb, asm, result, slotsRemaining, searchValue, vecCmp, vecArray, cmpResult, retFound, retNotFound);
// return -1 (no match) // return -1 (no match)
asm.bind(retNotFound); asm.bind(retNotFound);
@ -197,7 +202,7 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
asm.bind(end); asm.bind(end);
} }
private static void emitArrayIndexOfChars(CompilationResultBuilder crb, AMD64MacroAssembler asm, JavaKind kind, AVXKind.AVXSize vectorSize, private void emitArrayIndexOfChars(CompilationResultBuilder crb, AMD64MacroAssembler asm,
Register arrayPtr, Register arrayPtr,
Register slotsRemaining, Register slotsRemaining,
Register[] searchValue, Register[] searchValue,
@ -205,11 +210,10 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
Register[] vecArray, Register[] vecArray,
Register[] cmpResult, Register[] cmpResult,
Label retFound, Label retFound,
Label retNotFound, Label retNotFound) {
int vmPageSize, int nVectors = nValues == 1 ? 4 : nValues == 2 ? 2 : 1;
int nValues, AVXKind.AVXSize vectorSize = getVectorSize();
int nVectors,
boolean findTwoCharPrefix) {
Label bulkVectorLoop = new Label(); Label bulkVectorLoop = new Label();
Label singleVectorLoop = new Label(); Label singleVectorLoop = new Label();
Label[] vectorFound = { Label[] vectorFound = {
@ -229,7 +233,7 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
int bulkLoopCondition = bulkSize; int bulkLoopCondition = bulkSize;
int[] vectorOffsets; int[] vectorOffsets;
JavaKind vectorCompareKind = kind; JavaKind vectorCompareKind = kind;
if (findTwoCharPrefix) { if (findTwoConsecutive) {
singleVectorLoopCondition++; singleVectorLoopCondition++;
bulkLoopCondition++; bulkLoopCondition++;
bulkSize /= 2; bulkSize /= 2;
@ -274,7 +278,7 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
emitAlign(crb, asm); emitAlign(crb, asm);
asm.bind(bulkVectorLoop); asm.bind(bulkVectorLoop);
// memory-aligned bulk comparison // memory-aligned bulk comparison
emitVectorCompare(asm, vectorCompareKind, vectorSize, nValues, nVectors, vectorOffsets, arrayPtr, vecCmp, vecArray, cmpResult, vectorFound, !findTwoCharPrefix); emitVectorCompare(asm, vectorCompareKind, vectorSize, nValues, nVectors, vectorOffsets, arrayPtr, vecCmp, vecArray, cmpResult, vectorFound, !findTwoConsecutive);
// adjust number of array slots remaining // adjust number of array slots remaining
asm.subl(slotsRemaining, bulkSize); asm.subl(slotsRemaining, bulkSize);
// adjust array pointer // adjust array pointer
@ -293,7 +297,7 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
asm.cmpl(slotsRemaining, singleVectorLoopCondition); asm.cmpl(slotsRemaining, singleVectorLoopCondition);
asm.jcc(AMD64Assembler.ConditionFlag.Below, lessThanVectorSizeRemaining); asm.jcc(AMD64Assembler.ConditionFlag.Below, lessThanVectorSizeRemaining);
// compare // compare
emitVectorCompare(asm, vectorCompareKind, vectorSize, nValues, findTwoCharPrefix ? 2 : 1, vectorOffsets, arrayPtr, vecCmp, vecArray, cmpResult, vectorFound, false); emitVectorCompare(asm, vectorCompareKind, vectorSize, nValues, findTwoConsecutive ? 2 : 1, vectorOffsets, arrayPtr, vecCmp, vecArray, cmpResult, vectorFound, false);
// adjust number of array slots remaining // adjust number of array slots remaining
asm.subl(slotsRemaining, arraySlotsPerVector); asm.subl(slotsRemaining, arraySlotsPerVector);
// adjust array pointer // adjust array pointer
@ -313,16 +317,16 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
asm.movl(tmpArrayPtrLow, arrayPtr); asm.movl(tmpArrayPtrLow, arrayPtr);
// check if pointer + vector size would cross the page boundary // check if pointer + vector size would cross the page boundary
asm.andl(tmpArrayPtrLow, (vmPageSize - 1)); asm.andl(tmpArrayPtrLow, (vmPageSize - 1));
asm.cmpl(tmpArrayPtrLow, (vmPageSize - (findTwoCharPrefix ? bytesPerVector + kind.getByteCount() : bytesPerVector))); asm.cmpl(tmpArrayPtrLow, (vmPageSize - (findTwoConsecutive ? bytesPerVector + kind.getByteCount() : bytesPerVector)));
// if the page boundary would be crossed, do byte/character-wise comparison instead. // if the page boundary would be crossed, do byte/character-wise comparison instead.
asm.jccb(AMD64Assembler.ConditionFlag.Above, lessThanVectorSizeRemainingLoop); asm.jccb(AMD64Assembler.ConditionFlag.Above, lessThanVectorSizeRemainingLoop);
Label[] overBoundsMatch = {new Label(), new Label()}; Label[] overBoundsMatch = {new Label(), new Label()};
// otherwise, do a vector compare that reads beyond array bounds // otherwise, do a vector compare that reads beyond array bounds
emitVectorCompare(asm, vectorCompareKind, vectorSize, nValues, findTwoCharPrefix ? 2 : 1, vectorOffsets, arrayPtr, vecCmp, vecArray, cmpResult, overBoundsMatch, false); emitVectorCompare(asm, vectorCompareKind, vectorSize, nValues, findTwoConsecutive ? 2 : 1, vectorOffsets, arrayPtr, vecCmp, vecArray, cmpResult, overBoundsMatch, false);
// no match // no match
asm.jmp(retNotFound); asm.jmp(retNotFound);
if (findTwoCharPrefix) { if (findTwoConsecutive) {
Label overBoundsFinish = new Label(); Label overBoundsFinish = new Label();
asm.bind(overBoundsMatch[1]); asm.bind(overBoundsMatch[1]);
// get match offset of second result // get match offset of second result
@ -348,14 +352,14 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
} }
// check if offset of matched value is greater than number of bytes remaining / out of array // check if offset of matched value is greater than number of bytes remaining / out of array
// bounds // bounds
if (findTwoCharPrefix) { if (findTwoConsecutive) {
asm.decrementl(slotsRemaining); asm.decrementl(slotsRemaining);
} }
asm.cmpl(cmpResult[0], slotsRemaining); asm.cmpl(cmpResult[0], slotsRemaining);
// match is out of bounds, return no match // match is out of bounds, return no match
asm.jcc(AMD64Assembler.ConditionFlag.GreaterEqual, retNotFound); asm.jcc(AMD64Assembler.ConditionFlag.GreaterEqual, retNotFound);
// adjust number of array slots remaining // adjust number of array slots remaining
if (findTwoCharPrefix) { if (findTwoConsecutive) {
asm.incrementl(slotsRemaining, 1); asm.incrementl(slotsRemaining, 1);
} }
asm.subl(slotsRemaining, cmpResult[0]); asm.subl(slotsRemaining, cmpResult[0]);
@ -365,17 +369,17 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
// compare remaining slots in the array one-by-one // compare remaining slots in the array one-by-one
asm.bind(lessThanVectorSizeRemainingLoop); asm.bind(lessThanVectorSizeRemainingLoop);
// check if enough array slots remain // check if enough array slots remain
asm.cmpl(slotsRemaining, findTwoCharPrefix ? 1 : 0); asm.cmpl(slotsRemaining, findTwoConsecutive ? 1 : 0);
asm.jcc(AMD64Assembler.ConditionFlag.LessEqual, retNotFound); asm.jcc(AMD64Assembler.ConditionFlag.LessEqual, retNotFound);
// load char / byte // load char / byte
if (byteMode(kind)) { if (byteMode(kind)) {
if (findTwoCharPrefix) { if (findTwoConsecutive) {
asm.movzwl(cmpResult[0], new AMD64Address(arrayPtr)); asm.movzwl(cmpResult[0], new AMD64Address(arrayPtr));
} else { } else {
asm.movzbl(cmpResult[0], new AMD64Address(arrayPtr)); asm.movzbl(cmpResult[0], new AMD64Address(arrayPtr));
} }
} else { } else {
if (findTwoCharPrefix) { if (findTwoConsecutive) {
asm.movl(cmpResult[0], new AMD64Address(arrayPtr)); asm.movl(cmpResult[0], new AMD64Address(arrayPtr));
} else { } else {
asm.movzwl(cmpResult[0], new AMD64Address(arrayPtr)); asm.movzwl(cmpResult[0], new AMD64Address(arrayPtr));
@ -383,7 +387,7 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
} }
// check for match // check for match
for (int i = 0; i < nValues; i++) { for (int i = 0; i < nValues; i++) {
asm.cmpl(cmpResult[0], searchValue[i]); emitCompareInst(asm, getComparisonKind(), cmpResult[0], searchValue[i]);
asm.jcc(AMD64Assembler.ConditionFlag.Equal, retFound); asm.jcc(AMD64Assembler.ConditionFlag.Equal, retFound);
} }
// adjust number of array slots remaining // adjust number of array slots remaining
@ -393,11 +397,11 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
// continue loop // continue loop
asm.jmpb(lessThanVectorSizeRemainingLoop); asm.jmpb(lessThanVectorSizeRemainingLoop);
for (int i = 1; i < nVectors; i += (findTwoCharPrefix ? 2 : 1)) { for (int i = 1; i < nVectors; i += (findTwoConsecutive ? 2 : 1)) {
emitVectorFoundWithOffset(asm, kind, vectorOffsets[i], arrayPtr, cmpResult[i], slotsRemaining, vectorFound[i], retFound); emitVectorFoundWithOffset(asm, kind, vectorOffsets[i], arrayPtr, cmpResult[i], slotsRemaining, vectorFound[i], retFound);
} }
if (findTwoCharPrefix) { if (findTwoConsecutive) {
asm.bind(vectorFound[2]); asm.bind(vectorFound[2]);
asm.addq(arrayPtr, vectorOffsets[2]); asm.addq(arrayPtr, vectorOffsets[2]);
// adjust number of array slots remaining // adjust number of array slots remaining
@ -626,6 +630,23 @@ public final class AMD64ArrayIndexOfOp extends AMD64LIRInstruction {
} }
} }
private static void emitCompareInst(AMD64MacroAssembler asm, JavaKind kind, Register dst, Register src) {
switch (kind) {
case Byte:
asm.cmpb(dst, src);
break;
case Short:
case Char:
asm.cmpw(dst, src);
break;
case Int:
asm.cmpl(dst, src);
break;
default:
asm.cmpq(dst, src);
}
}
private static boolean supportsAVX2(LIRGeneratorTool tool) { private static boolean supportsAVX2(LIRGeneratorTool tool) {
return supports(tool, CPUFeature.AVX2); return supports(tool, CPUFeature.AVX2);
} }

View file

@ -185,7 +185,7 @@ class ConsoleIOContext extends IOContext {
it.set(current); it.set(current);
} }
historyLoad = Instant.now(); historyLoad = Instant.MIN;
loadHistory.forEach(line -> reader.getHistory().add(historyLoad, line)); loadHistory.forEach(line -> reader.getHistory().add(historyLoad, line));
in = reader; in = reader;

View file

@ -85,7 +85,6 @@ gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8193639 solaris-all
runtime/appcds/javaldr/GCSharedStringsDuringDump.java 8208778 macosx-x64 runtime/appcds/javaldr/GCSharedStringsDuringDump.java 8208778 macosx-x64
runtime/appcds/javaldr/GCDuringDump.java 8208778 macosx-x64 runtime/appcds/javaldr/GCDuringDump.java 8208778 macosx-x64
runtime/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java 8213299 generic-all
runtime/CompressedOops/UseCompressedOops.java 8079353 generic-all runtime/CompressedOops/UseCompressedOops.java 8079353 generic-all
runtime/handshake/HandshakeWalkSuspendExitTest.java 8214174 generic-all runtime/handshake/HandshakeWalkSuspendExitTest.java 8214174 generic-all
runtime/RedefineTests/RedefineRunningMethods.java 8208778 macosx-x64 runtime/RedefineTests/RedefineRunningMethods.java 8208778 macosx-x64

View file

@ -0,0 +1,93 @@
/*
* Copyright (c) 2019, Red Hat, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8216549
* @summary Mismatched unsafe access to non escaping object fails
*
* @modules java.base/jdk.internal.misc
* @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation MismatchedUnsafeLoadFromNewObject
*/
import java.lang.reflect.Field;
import jdk.internal.misc.Unsafe;
public class MismatchedUnsafeLoadFromNewObject {
public volatile int f_int = -1;
public volatile int f_int2 = -1;
public static Unsafe unsafe = Unsafe.getUnsafe();
public static final long f_int_off;
public static final long f_int2_off;
static {
Field f_int_field = null;
Field f_int2_field = null;
try {
f_int_field = MismatchedUnsafeLoadFromNewObject.class.getField("f_int");
f_int2_field = MismatchedUnsafeLoadFromNewObject.class.getField("f_int2");
} catch (Exception e) {
System.out.println("reflection failed " + e);
e.printStackTrace();
}
f_int_off = unsafe.objectFieldOffset(f_int_field);
f_int2_off = unsafe.objectFieldOffset(f_int2_field);
}
static public void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
byte res = test1();
if (res != -1) {
throw new RuntimeException("Incorrect result: " + res);
}
res = test2();
if (res != -1) {
throw new RuntimeException("Incorrect result: " + res);
}
int res2 = test3();
if (res2 != -1) {
throw new RuntimeException("Incorrect result: " + res2);
}
}
}
static byte test1() {
MismatchedUnsafeLoadFromNewObject t = new MismatchedUnsafeLoadFromNewObject();
return unsafe.getByte(t, f_int_off);
}
static byte test2() {
MismatchedUnsafeLoadFromNewObject t = new MismatchedUnsafeLoadFromNewObject();
return unsafe.getByte(t, f_int_off+1);
}
static int test3() {
MismatchedUnsafeLoadFromNewObject t = new MismatchedUnsafeLoadFromNewObject();
if (f_int_off < f_int2_off) {
return unsafe.getIntUnaligned(t, f_int_off+1);
} else {
return unsafe.getIntUnaligned(t, f_int2_off+1);
}
}
}

View file

@ -583,7 +583,6 @@ java/nio/file/WatchService/MayFlies.java 7158947 solaris-
java/nio/file/WatchService/LotsOfCancels.java 8188039 solaris-all Solaris 11 java/nio/file/WatchService/LotsOfCancels.java 8188039 solaris-all Solaris 11
java/nio/file/WatchService/LotsOfEvents.java 7158947 solaris-all Solaris 11 java/nio/file/WatchService/LotsOfEvents.java 7158947 solaris-all Solaris 11
sun/nio/cs/OLD/TestIBMDB.java 8211841 aix-ppc64
############################################################################ ############################################################################

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, 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
@ -67,7 +67,6 @@ public class CondyDescTest extends SymbolicDescTest {
private void testVarHandleDesc(DynamicConstantDesc<VarHandle> r, VarHandle vh) throws ReflectiveOperationException { private void testVarHandleDesc(DynamicConstantDesc<VarHandle> r, VarHandle vh) throws ReflectiveOperationException {
testSymbolicDesc(r); testSymbolicDesc(r);
assertEquals(r.resolveConstantDesc(LOOKUP), vh);
assertEquals(vh.describeConstable().orElseThrow(), r); assertEquals(vh.describeConstable().orElseThrow(), r);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -141,8 +141,6 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -141,8 +141,6 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -141,8 +141,6 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -141,8 +141,6 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -141,8 +141,6 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -141,8 +141,6 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -141,8 +141,6 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -141,8 +141,6 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -143,8 +143,6 @@ public class VarHandleTestAccessString extends VarHandleBaseTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -93,8 +93,6 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -93,8 +93,6 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -93,8 +93,6 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -93,8 +93,6 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -93,8 +93,6 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, 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
@ -93,8 +93,6 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i == j) {
assertEquals(vhs1[i], vhs1[i]); assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
} }
else { else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);

View file

@ -31,7 +31,7 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.nio.charset.CharacterCodingException; import java.nio.charset.CharacterCodingException;
import sun.nio.cs.HistoricallyNamedCharset; import sun.nio.cs.*;
import sun.nio.cs.ext.*; import sun.nio.cs.ext.*;

View file

@ -31,7 +31,7 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.nio.charset.CharacterCodingException; import java.nio.charset.CharacterCodingException;
import sun.nio.cs.HistoricallyNamedCharset; import sun.nio.cs.*;
import sun.nio.cs.ext.*; import sun.nio.cs.ext.*;

View file

@ -30,7 +30,7 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.nio.charset.CharacterCodingException; import java.nio.charset.CharacterCodingException;
import sun.nio.cs.HistoricallyNamedCharset; import sun.nio.cs.*;
import sun.nio.cs.ext.*; import sun.nio.cs.ext.*;

View file

@ -30,7 +30,7 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.nio.charset.CharacterCodingException; import java.nio.charset.CharacterCodingException;
import sun.nio.cs.HistoricallyNamedCharset; import sun.nio.cs.*;
import sun.nio.cs.ext.*; import sun.nio.cs.ext.*;

View file

@ -33,8 +33,7 @@ import java.nio.CharBuffer;
import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult; import java.nio.charset.CoderResult;
import sun.nio.cs.HistoricallyNamedCharset; import sun.nio.cs.*;
import sun.nio.cs.Surrogate;
import sun.nio.cs.ext.*; import sun.nio.cs.ext.*;