8005816: Shark: fix volatile float field access
authortwisti
Fri, 11 Jan 2013 16:47:23 -0800
changeset 15204 a8960bf92b09
parent 15203 e0a182db881c
child 15205 17da82a12ff4
8005816: Shark: fix volatile float field access Reviewed-by: twisti Contributed-by: Roman Kennke <rkennke@redhat.com>
hotspot/src/share/vm/shark/sharkBlock.cpp
--- a/hotspot/src/share/vm/shark/sharkBlock.cpp	Fri Jan 11 14:07:09 2013 -0800
+++ b/hotspot/src/share/vm/shark/sharkBlock.cpp	Fri Jan 11 16:47:23 2013 -0800
@@ -1044,10 +1044,17 @@
     BasicType   basic_type = field->type()->basic_type();
     Type *stack_type = SharkType::to_stackType(basic_type);
     Type *field_type = SharkType::to_arrayType(basic_type);
-
+    Type *type = field_type;
+    if (field->is_volatile()) {
+      if (field_type == SharkType::jfloat_type()) {
+        type = SharkType::jint_type();
+      } else if (field_type == SharkType::jdouble_type()) {
+        type = SharkType::jlong_type();
+      }
+    }
     Value *addr = builder()->CreateAddressOfStructEntry(
       object, in_ByteSize(field->offset_in_bytes()),
-      PointerType::getUnqual(field_type),
+      PointerType::getUnqual(type),
       "addr");
 
     // Do the access
@@ -1055,6 +1062,7 @@
       Value* field_value;
       if (field->is_volatile()) {
         field_value = builder()->CreateAtomicLoad(addr);
+        field_value = builder()->CreateBitCast(field_value, field_type);
       } else {
         field_value = builder()->CreateLoad(addr);
       }
@@ -1074,6 +1082,7 @@
       }
 
       if (field->is_volatile()) {
+        field_value = builder()->CreateBitCast(field_value, type);
         builder()->CreateAtomicStore(field_value, addr);
       } else {
         builder()->CreateStore(field_value, addr);