1.1 --- a/src/share/vm/interpreter/bytecodeInterpreter.cpp Wed Dec 11 00:06:11 2013 +0100 1.2 +++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp Wed Dec 11 12:28:09 2013 +0100 1.3 @@ -2240,6 +2240,9 @@ 1.4 } 1.5 result->set_klass_gap(0); 1.6 result->set_klass(k_entry); 1.7 + // Must prevent reordering of stores for object initialization 1.8 + // with stores that publish the new object. 1.9 + OrderAccess::storestore(); 1.10 SET_STACK_OBJECT(result, 0); 1.11 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1); 1.12 } 1.13 @@ -2248,6 +2251,9 @@ 1.14 // Slow case allocation 1.15 CALL_VM(InterpreterRuntime::_new(THREAD, METHOD->constants(), index), 1.16 handle_exception); 1.17 + // Must prevent reordering of stores for object initialization 1.18 + // with stores that publish the new object. 1.19 + OrderAccess::storestore(); 1.20 SET_STACK_OBJECT(THREAD->vm_result(), 0); 1.21 THREAD->set_vm_result(NULL); 1.22 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1); 1.23 @@ -2257,6 +2263,9 @@ 1.24 jint size = STACK_INT(-1); 1.25 CALL_VM(InterpreterRuntime::anewarray(THREAD, METHOD->constants(), index, size), 1.26 handle_exception); 1.27 + // Must prevent reordering of stores for object initialization 1.28 + // with stores that publish the new object. 1.29 + OrderAccess::storestore(); 1.30 SET_STACK_OBJECT(THREAD->vm_result(), -1); 1.31 THREAD->set_vm_result(NULL); 1.32 UPDATE_PC_AND_CONTINUE(3); 1.33 @@ -2271,6 +2280,9 @@ 1.34 //adjust pointer to start of stack element 1.35 CALL_VM(InterpreterRuntime::multianewarray(THREAD, dimarray), 1.36 handle_exception); 1.37 + // Must prevent reordering of stores for object initialization 1.38 + // with stores that publish the new object. 1.39 + OrderAccess::storestore(); 1.40 SET_STACK_OBJECT(THREAD->vm_result(), -dims); 1.41 THREAD->set_vm_result(NULL); 1.42 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -(dims-1)); 1.43 @@ -2693,6 +2705,9 @@ 1.44 jint size = STACK_INT(-1); 1.45 CALL_VM(InterpreterRuntime::newarray(THREAD, atype, size), 1.46 handle_exception); 1.47 + // Must prevent reordering of stores for object initialization 1.48 + // with stores that publish the new object. 1.49 + OrderAccess::storestore(); 1.50 SET_STACK_OBJECT(THREAD->vm_result(), -1); 1.51 THREAD->set_vm_result(NULL); 1.52 1.53 @@ -2926,6 +2941,12 @@ 1.54 } // handle_Early_Return 1.55 1.56 handle_return: { 1.57 + // A storestore barrier is required to order initialization of 1.58 + // final fields with publishing the reference to the object that 1.59 + // holds the field. Without the barrier the value of final fields 1.60 + // can be observed to change. 1.61 + OrderAccess::storestore(); 1.62 + 1.63 DECACHE_STATE(); 1.64 1.65 bool suppress_error = istate->msg() == popping_frame || istate->msg() == early_return;