--- old/src/share/vm/opto/output.cpp 2016-10-25 10:40:07.985776739 +0200 +++ new/src/share/vm/opto/output.cpp 2016-10-25 10:40:07.937776707 +0200 @@ -984,7 +984,8 @@ class NonSafepointEmitter { Compile* C; JVMState* _pending_jvms; - int _pending_offset; + int _pending_begin_offset; + int _pending_end_offset; void emit_non_safepoint(); @@ -992,7 +993,8 @@ NonSafepointEmitter(Compile* compile) { this->C = compile; _pending_jvms = NULL; - _pending_offset = 0; + _pending_begin_offset = 0; + _pending_end_offset = 0; } void observe_instruction(Node* n, int pc_offset) { @@ -1003,17 +1005,22 @@ if (_pending_jvms != NULL && _pending_jvms->same_calls_as(nn->jvms())) { // Repeated JVMS? Stretch it up here. - _pending_offset = pc_offset; + _pending_end_offset = pc_offset; } else { - if (_pending_jvms != NULL && - _pending_offset < pc_offset) { - emit_non_safepoint(); + if (_pending_jvms != NULL) { + if (_pending_end_offset < pc_offset) { + emit_non_safepoint(); + } else if (_pending_begin_offset < pc_offset) { + // stretch as far as possible before the conflict + _pending_end_offset = pc_offset - 1; + emit_non_safepoint(); + } } _pending_jvms = NULL; if (pc_offset > C->debug_info()->last_pc_offset()) { // This is the only way _pending_jvms can become non-NULL: _pending_jvms = nn->jvms(); - _pending_offset = pc_offset; + _pending_begin_offset = _pending_end_offset = pc_offset; } } } @@ -1022,7 +1029,7 @@ void observe_safepoint(JVMState* jvms, int pc_offset) { if (_pending_jvms != NULL && !_pending_jvms->same_calls_as(jvms) && - _pending_offset < pc_offset) { + _pending_end_offset < pc_offset) { emit_non_safepoint(); } _pending_jvms = NULL; @@ -1038,7 +1045,7 @@ void NonSafepointEmitter::emit_non_safepoint() { JVMState* youngest_jvms = _pending_jvms; - int pc_offset = _pending_offset; + int pc_offset = _pending_end_offset; // Clear it now: _pending_jvms = NULL;