United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7010665 Misplaced membar in C1 implementation of Unsafe.get/putXXX
JDK-7010665 : Misplaced membar in C1 implementation of Unsafe.get/putXXX

Details
Type:
Bug
Submit Date:
2011-01-06
Status:
Closed
Updated Date:
2011-04-23
Project Name:
JDK
Resolved Date:
2011-04-23
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
hs20
Fixed Versions:
hs20 (b07)

Related Reports
Backport:
Backport:

Sub Tasks

Description
The C1 shared code for generating the intrinsics for the Unsafe.getXXX and Unsafe.putXXX is:

void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) {
  ...
  if (x->is_volatile() && os::is_MP()) __ membar_acquire();
  get_Object_unsafe(reg, src.result(), off.result(), type, x->is_volatile());
  if (x->is_volatile() && os::is_MP()) __ membar();
}

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());
} 

Note that "get" has a final membar(), but it is the "put" that needs it.

Also "get" should be "load; acquire" not "acquire; load"

                                    

Comments
EVALUATION

Correct formulation should be:

void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) {
  ...
  get_Object_unsafe(reg, src.result(), off.result(), type, x->is_volatile());
  if (x->is_volatile() && os::is_MP()) __ membar_acquire();
}

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();
}
                                     
2011-01-06
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/df307487d610
                                     
2011-01-10
PUBLIC COMMENTS

Test comment for public access
                                     
2011-01-10
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot/hotspot/rev/df307487d610
                                     
2011-01-14



Hardware and Software, Engineered to Work Together