@@ -135,9 +135,20 @@ void LIR_Assembler::osr_entry() {
135135 // copied into place by code emitted in the IR.
136136
137137 Register OSR_buf = osrBufferPointer ()->as_register ();
138- { assert (frame::interpreter_frame_monitor_size () == BasicObjectLock::size (), " adjust code below" );
139- int monitor_offset = BytesPerWord * method ()->max_locals () +
140- (2 * BytesPerWord) * (number_of_locks - 1 );
138+ {
139+ assert (frame::interpreter_frame_monitor_size () == BasicObjectLock::size (), " adjust code below" );
140+
141+ const int locals_space = BytesPerWord * method ()->max_locals ();
142+ int monitor_offset = locals_space + (2 * BytesPerWord) * (number_of_locks - 1 );
143+ bool use_OSR_bias = false ;
144+
145+ if (!Assembler::is_simm16 (monitor_offset + BytesPerWord) && number_of_locks > 0 ) {
146+ // Offsets too large for ld instructions. Use bias.
147+ __ add_const_optimized (OSR_buf, OSR_buf, locals_space);
148+ monitor_offset -= locals_space;
149+ use_OSR_bias = true ;
150+ }
151+
141152 // SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in
142153 // the OSR buffer using 2 word entries: first the lock and then
143154 // the oop.
@@ -163,6 +174,11 @@ void LIR_Assembler::osr_entry() {
163174 __ ld (R0, slot_offset + 1 *BytesPerWord, OSR_buf);
164175 __ std (R0, mo.disp (), mo.base ());
165176 }
177+
178+ if (use_OSR_bias) {
179+ // Restore.
180+ __ sub_const_optimized (OSR_buf, OSR_buf, locals_space);
181+ }
166182 }
167183}
168184
0 commit comments