Fri, 11 Jan 2013 16:47:23 -0800
8005816: Shark: fix volatile float field access
Reviewed-by: twisti
Contributed-by: Roman Kennke <rkennke@redhat.com>
src/share/vm/shark/sharkBlock.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/shark/sharkBlock.cpp Fri Jan 11 14:07:09 2013 -0800 1.2 +++ b/src/share/vm/shark/sharkBlock.cpp Fri Jan 11 16:47:23 2013 -0800 1.3 @@ -1044,10 +1044,17 @@ 1.4 BasicType basic_type = field->type()->basic_type(); 1.5 Type *stack_type = SharkType::to_stackType(basic_type); 1.6 Type *field_type = SharkType::to_arrayType(basic_type); 1.7 - 1.8 + Type *type = field_type; 1.9 + if (field->is_volatile()) { 1.10 + if (field_type == SharkType::jfloat_type()) { 1.11 + type = SharkType::jint_type(); 1.12 + } else if (field_type == SharkType::jdouble_type()) { 1.13 + type = SharkType::jlong_type(); 1.14 + } 1.15 + } 1.16 Value *addr = builder()->CreateAddressOfStructEntry( 1.17 object, in_ByteSize(field->offset_in_bytes()), 1.18 - PointerType::getUnqual(field_type), 1.19 + PointerType::getUnqual(type), 1.20 "addr"); 1.21 1.22 // Do the access 1.23 @@ -1055,6 +1062,7 @@ 1.24 Value* field_value; 1.25 if (field->is_volatile()) { 1.26 field_value = builder()->CreateAtomicLoad(addr); 1.27 + field_value = builder()->CreateBitCast(field_value, field_type); 1.28 } else { 1.29 field_value = builder()->CreateLoad(addr); 1.30 } 1.31 @@ -1074,6 +1082,7 @@ 1.32 } 1.33 1.34 if (field->is_volatile()) { 1.35 + field_value = builder()->CreateBitCast(field_value, type); 1.36 builder()->CreateAtomicStore(field_value, addr); 1.37 } else { 1.38 builder()->CreateStore(field_value, addr);