@@ -166,6 +166,7 @@ void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
166166 Register temp_reg, bool load_bc_into_bc_reg/* =true*/ ,
167167 int byte_no)
168168{
169+ assert_different_registers (bc_reg, temp_reg);
169170 if (!RewriteBytecodes) return ;
170171 Label L_patch_done;
171172
@@ -223,8 +224,12 @@ void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
223224 __ bind (L_okay);
224225#endif
225226
226- // patch bytecode
227- __ strb (bc_reg, at_bcp (0 ));
227+ // Patch bytecode with release store to coordinate with ConstantPoolCacheEntry loads
228+ // in fast bytecode codelets. The fast bytecode codelets have a memory barrier that gains
229+ // the needed ordering, together with control dependency on entering the fast codelet
230+ // itself.
231+ __ lea (temp_reg, at_bcp (0 ));
232+ __ stlrb (bc_reg, temp_reg);
228233 __ bind (L_patch_done);
229234}
230235
@@ -2982,6 +2987,7 @@ void TemplateTable::fast_storefield(TosState state)
29822987
29832988 // replace index with field offset from cache entry
29842989 __ ldr (r1, Address (r2, in_bytes (base + ConstantPoolCacheEntry::f2_offset ())));
2990+ __ verify_field_offset (r1);
29852991
29862992 {
29872993 Label notVolatile;
@@ -3075,6 +3081,8 @@ void TemplateTable::fast_accessfield(TosState state)
30753081
30763082 __ ldr (r1, Address (r2, in_bytes (ConstantPoolCache::base_offset () +
30773083 ConstantPoolCacheEntry::f2_offset ())));
3084+ __ verify_field_offset (r1);
3085+
30783086 __ ldrw (r3, Address (r2, in_bytes (ConstantPoolCache::base_offset () +
30793087 ConstantPoolCacheEntry::flags_offset ())));
30803088
@@ -3142,8 +3150,13 @@ void TemplateTable::fast_xaccess(TosState state)
31423150 __ ldr (r0, aaddress (0 ));
31433151 // access constant pool cache
31443152 __ get_cache_and_index_at_bcp (r2, r3, 2 );
3153+
3154+ // Must prevent reordering of the following cp cache loads with bytecode load
3155+ __ membar (MacroAssembler::LoadLoad);
3156+
31453157 __ ldr (r1, Address (r2, in_bytes (ConstantPoolCache::base_offset () +
31463158 ConstantPoolCacheEntry::f2_offset ())));
3159+ __ verify_field_offset (r1);
31473160
31483161 // 8179954: We need to make sure that the code generated for
31493162 // volatile accesses forms a sequentially-consistent set of
0 commit comments