@@ -131,6 +131,7 @@ Address TemplateTable::at_bcp(int offset) {
131131void TemplateTable::patch_bytecode (Bytecodes::Code bc, Register bc_reg,
132132 Register temp_reg, bool load_bc_into_bc_reg /* =true*/ ,
133133 int byte_no) {
134+ assert_different_registers (bc_reg, temp_reg);
134135 if (!RewriteBytecodes) { return ; }
135136 Label L_patch_done;
136137
@@ -186,7 +187,11 @@ void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
186187 __ bind (L_okay);
187188#endif
188189
189- // patch bytecode
190+ // Patch bytecode with release store to coordinate with ResolvedFieldEntry loads
191+ // in fast bytecode codelets. load_field_entry has a memory barrier that gains
192+ // the needed ordering, together with control dependency on entering the fast codelet
193+ // itself.
194+ __ membar (MacroAssembler::LoadStore | MacroAssembler::StoreStore);
190195 __ sb (bc_reg, at_bcp (0 ));
191196 __ bind (L_patch_done);
192197}
@@ -2908,6 +2913,7 @@ void TemplateTable::fast_storefield(TosState state) {
29082913
29092914 // replace index with field offset from cache entry
29102915 __ ld (x11, Address (x12, in_bytes (base + ConstantPoolCacheEntry::f2_offset ())));
2916+ __ verify_field_offset (x11);
29112917
29122918 {
29132919 Label notVolatile;
@@ -3003,6 +3009,8 @@ void TemplateTable::fast_accessfield(TosState state) {
30033009
30043010 __ ld (x11, Address (x12, in_bytes (ConstantPoolCache::base_offset () +
30053011 ConstantPoolCacheEntry::f2_offset ())));
3012+ __ verify_field_offset (x11);
3013+
30063014 __ lwu (x13, Address (x12, in_bytes (ConstantPoolCache::base_offset () +
30073015 ConstantPoolCacheEntry::flags_offset ())));
30083016
@@ -3059,8 +3067,13 @@ void TemplateTable::fast_xaccess(TosState state) {
30593067 __ ld (x10, aaddress (0 ));
30603068 // access constant pool cache
30613069 __ get_cache_and_index_at_bcp (x12, x13, 2 );
3070+
3071+ // Must prevent reordering of the following cp cache loads with bytecode load
3072+ __ membar (MacroAssembler::LoadLoad);
3073+
30623074 __ ld (x11, Address (x12, in_bytes (ConstantPoolCache::base_offset () +
30633075 ConstantPoolCacheEntry::f2_offset ())));
3076+ __ verify_field_offset (x11);
30643077
30653078 // make sure exception is reported in correct bcp range (getfield is
30663079 // next instruction)
0 commit comments