# HG changeset patch # User mdoerr # Date 1444081616 -7200 # Node ID 8054005171414fef5f53b6c446efcbb638bdff29 # Parent daf8acf3afdab4da6795138194cf064ff5910c7e 8138894: C1: Support IRIW on weak memory platforms Reviewed-by: diff --git a/src/share/vm/c1/c1_GraphBuilder.cpp b/src/share/vm/c1/c1_GraphBuilder.cpp --- a/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/src/share/vm/c1/c1_GraphBuilder.cpp @@ -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; diff --git a/src/share/vm/c1/c1_IR.cpp b/src/share/vm/c1/c1_IR.cpp --- a/src/share/vm/c1/c1_IR.cpp +++ b/src/share/vm/c1/c1_IR.cpp @@ -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) { diff --git a/src/share/vm/c1/c1_IR.hpp b/src/share/vm/c1/c1_IR.hpp --- a/src/share/vm/c1/c1_IR.hpp +++ b/src/share/vm/c1/c1_IR.hpp @@ -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_final = true; } + bool wrote_volatile () const { return _wrote_final; } }; diff --git a/src/share/vm/c1/c1_LIRGenerator.cpp b/src/share/vm/c1/c1_LIRGenerator.cpp --- a/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/src/share/vm/c1/c1_LIRGenerator.cpp @@ -1758,7 +1758,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(); } } @@ -1819,6 +1819,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); @@ -2235,6 +2239,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 @@ -2392,7 +2400,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(); }