8138894: C1: Support IRIW on weak memory platforms

Reviewed-by: twisti, goetz
This commit is contained in:
Martin Doerr 2015-10-21 10:37:50 +02:00
parent 26f02e4686
commit 9a5f4d56ff
4 changed files with 22 additions and 6 deletions

View File

@ -1438,7 +1438,9 @@ void GraphBuilder::method_return(Value x) {
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 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
if (code == Bytecodes::_putfield) {
scope()->set_wrote_fields();
if (field->is_volatile()) {
scope()->set_wrote_volatile();
}
}
const int offset = !needs_patching ? field->offset() : -1;

View File

@ -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 @@ IRScope::IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMe
_monitor_pairing_ok = method->has_balanced_monitors();
_wrote_final = false;
_wrote_fields = false;
_wrote_volatile = false;
_start = NULL;
if (osr_bci == -1) {

View File

@ -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 @@ class IRScope: public CompilationResourceObj {
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 @@ class IRScope: public CompilationResourceObj {
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; }
};

View File

@ -1761,7 +1761,7 @@ void LIRGenerator::do_StoreField(StoreField* x) {
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 @@ void LIRGenerator::do_LoadField(LoadField* x) {
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 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) {
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 @@ void LIRGenerator::do_UnsafePutObject(UnsafePutObject* x) {
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();
}