--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Fri Nov 06 10:06:51 2015 -1000
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Wed Oct 21 10:37:50 2015 +0200
@@ -1438,7 +1438,9 @@
bool need_mem_bar = false;
if (method()->name() == ciSymbol::object_initializer_name() &&
- (scope()->wrote_final() || (AlwaysSafeConstructors && scope()->wrote_fields()))) {
+ (scope()->wrote_final() || (AlwaysSafeConstructors && scope()->wrote_fields())
+ || (support_IRIW_for_not_multiple_copy_atomic_cpu && scope()->wrote_volatile())
+ )){
need_mem_bar = true;
}
@@ -1554,6 +1556,9 @@
if (code == Bytecodes::_putfield) {
scope()->set_wrote_fields();
+ if (field->is_volatile()) {
+ scope()->set_wrote_volatile();
+ }
}
const int offset = !needs_patching ? field->offset() : -1;
--- a/hotspot/src/share/vm/c1/c1_IR.cpp Fri Nov 06 10:06:51 2015 -1000
+++ b/hotspot/src/share/vm/c1/c1_IR.cpp Wed Oct 21 10:37:50 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. 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
@@ -143,6 +143,7 @@
_monitor_pairing_ok = method->has_balanced_monitors();
_wrote_final = false;
_wrote_fields = false;
+ _wrote_volatile = false;
_start = NULL;
if (osr_bci == -1) {
--- a/hotspot/src/share/vm/c1/c1_IR.hpp Fri Nov 06 10:06:51 2015 -1000
+++ b/hotspot/src/share/vm/c1/c1_IR.hpp Wed Oct 21 10:37:50 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. 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
@@ -151,6 +151,7 @@
bool _monitor_pairing_ok; // the monitor pairing info
bool _wrote_final; // has written final field
bool _wrote_fields; // has written fields
+ bool _wrote_volatile; // has written volatile field
BlockBegin* _start; // the start block, successsors are method entries
BitMap _requires_phi_function; // bit is set if phi functions at loop headers are necessary for a local variable
@@ -187,7 +188,8 @@
bool wrote_final () const { return _wrote_final; }
void set_wrote_fields() { _wrote_fields = true; }
bool wrote_fields () const { return _wrote_fields; }
-
+ void set_wrote_volatile() { _wrote_volatile = true; }
+ bool wrote_volatile () const { return _wrote_volatile; }
};
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Fri Nov 06 10:06:51 2015 -1000
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Wed Oct 21 10:37:50 2015 +0200
@@ -1761,7 +1761,7 @@
post_barrier(object.result(), value.result());
}
- if (is_volatile && os::is_MP()) {
+ if (!support_IRIW_for_not_multiple_copy_atomic_cpu && is_volatile && os::is_MP()) {
__ membar();
}
}
@@ -1822,6 +1822,10 @@
address = generate_address(object.result(), x->offset(), field_type);
}
+ if (support_IRIW_for_not_multiple_copy_atomic_cpu && is_volatile && os::is_MP()) {
+ __ membar();
+ }
+
bool needs_atomic_access = is_volatile || AlwaysAtomicAccesses;
if (needs_atomic_access && !needs_patching) {
volatile_field_load(address, reg, info);
@@ -2238,6 +2242,10 @@
LIR_Opr value = rlock_result(x, x->basic_type());
+ if (support_IRIW_for_not_multiple_copy_atomic_cpu && x->is_volatile() && os::is_MP()) {
+ __ membar();
+ }
+
get_Object_unsafe(value, src.result(), off.result(), type, x->is_volatile());
#if INCLUDE_ALL_GCS
@@ -2395,7 +2403,7 @@
if (x->is_volatile() && os::is_MP()) __ membar_release();
put_Object_unsafe(src.result(), off.result(), data.result(), type, x->is_volatile());
- if (x->is_volatile() && os::is_MP()) __ membar();
+ if (!support_IRIW_for_not_multiple_copy_atomic_cpu && x->is_volatile() && os::is_MP()) __ membar();
}