Merge

Fri, 14 Jul 2017 11:35:22 -0700

author
asaha
date
Fri, 14 Jul 2017 11:35:22 -0700
changeset 8991
7bcf6e0c266c
parent 8985
01b347e2b10b
parent 8990
7245ee7fa44a
child 8992
3dd062a38713

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Fri Jul 14 11:00:50 2017 -0700
     1.2 +++ b/.hgtags	Fri Jul 14 11:35:22 2017 -0700
     1.3 @@ -985,6 +985,8 @@
     1.4  df6af363337eff5b22ae7940b0981231fdf5dfb4 jdk8u141-b13
     1.5  3a1543e089c32592be9c201c6e021295fbf5fdc1 jdk8u141-b14
     1.6  23f1790147d838ddb1133cc79dc08e7c9ba5ab44 jdk8u141-b15
     1.7 +9ffa0d7ed932045a0b4ceb095fb52444eed39c1b jdk8u141-b31
     1.8 +ae8cae699f62b845703c891e0e7633e2089a3ec4 jdk8u141-b32
     1.9  2d5100bddeb80cf767485b787fc3051311e3d7b9 jdk8u151-b00
    1.10  596b584c68b73ec635347807571463580deb955f jdk8u151-b01
    1.11  1f6f436360d5cd375b806aec1c78abb8fcb4e5f6 jdk8u151-b02
     2.1 --- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Fri Jul 14 11:00:50 2017 -0700
     2.2 +++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Fri Jul 14 11:35:22 2017 -0700
     2.3 @@ -98,7 +98,7 @@
     2.4    }
     2.5    pop(rax);
     2.6  #endif
     2.7 -  reset_last_Java_frame(thread, true, align_stack);
     2.8 +  reset_last_Java_frame(thread, true);
     2.9  
    2.10    // discard thread and arguments
    2.11    NOT_LP64(addptr(rsp, num_rt_args()*BytesPerWord));
    2.12 @@ -882,7 +882,7 @@
    2.13    }
    2.14    __ pop(rax);
    2.15  #endif
    2.16 -  __ reset_last_Java_frame(thread, true, false);
    2.17 +  __ reset_last_Java_frame(thread, true);
    2.18  #ifndef _LP64
    2.19    __ pop(rcx); // discard thread arg
    2.20    __ pop(rcx); // discard dummy
     3.1 --- a/src/cpu/x86/vm/frame_x86.cpp	Fri Jul 14 11:00:50 2017 -0700
     3.2 +++ b/src/cpu/x86/vm/frame_x86.cpp	Fri Jul 14 11:35:22 2017 -0700
     3.3 @@ -370,13 +370,16 @@
     3.4    JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
     3.5    assert(!entry_frame_is_first(), "next Java fp must be non zero");
     3.6    assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
     3.7 +  // Since we are walking the stack now this nested anchor is obviously walkable
     3.8 +  // even if it wasn't when it was stacked.
     3.9 +  if (!jfa->walkable()) {
    3.10 +    // Capture _last_Java_pc (if needed) and mark anchor walkable.
    3.11 +    jfa->capture_last_Java_pc();
    3.12 +  }
    3.13    map->clear();
    3.14    assert(map->include_argument_oops(), "should be set by clear");
    3.15 -  if (jfa->last_Java_pc() != NULL ) {
    3.16 -    frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
    3.17 -    return fr;
    3.18 -  }
    3.19 -  frame fr(jfa->last_Java_sp(), jfa->last_Java_fp());
    3.20 +  assert(jfa->last_Java_pc() != NULL, "not walkable");
    3.21 +  frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
    3.22    return fr;
    3.23  }
    3.24  
    3.25 @@ -714,3 +717,21 @@
    3.26    init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
    3.27  }
    3.28  #endif
    3.29 +
    3.30 +void JavaFrameAnchor::make_walkable(JavaThread* thread) {
    3.31 +  // last frame set?
    3.32 +  if (last_Java_sp() == NULL) return;
    3.33 +  // already walkable?
    3.34 +  if (walkable()) return;
    3.35 +  assert(Thread::current() == (Thread*)thread, "not current thread");
    3.36 +  assert(last_Java_sp() != NULL, "not called from Java code?");
    3.37 +  assert(last_Java_pc() == NULL, "already walkable");
    3.38 +  capture_last_Java_pc();
    3.39 +  assert(walkable(), "something went wrong");
    3.40 +}
    3.41 +
    3.42 +void JavaFrameAnchor::capture_last_Java_pc() {
    3.43 +  assert(_last_Java_sp != NULL, "no last frame set");
    3.44 +  assert(_last_Java_pc == NULL, "already walkable");
    3.45 +  _last_Java_pc = (address)_last_Java_sp[-1];
    3.46 +}
     4.1 --- a/src/cpu/x86/vm/frame_x86.inline.hpp	Fri Jul 14 11:00:50 2017 -0700
     4.2 +++ b/src/cpu/x86/vm/frame_x86.inline.hpp	Fri Jul 14 11:35:22 2017 -0700
     4.3 @@ -96,6 +96,7 @@
     4.4    // call a specialized frame constructor instead of this one.
     4.5    // Then we could use the assert below. However this assert is of somewhat dubious
     4.6    // value.
     4.7 +  // UPDATE: this constructor is only used by trace_method_handle_stub() now.
     4.8    // assert(_pc != NULL, "no pc?");
     4.9  
    4.10    _cb = CodeCache::find_blob(_pc);
     5.1 --- a/src/cpu/x86/vm/javaFrameAnchor_x86.hpp	Fri Jul 14 11:00:50 2017 -0700
     5.2 +++ b/src/cpu/x86/vm/javaFrameAnchor_x86.hpp	Fri Jul 14 11:35:22 2017 -0700
     5.3 @@ -62,10 +62,9 @@
     5.4      _last_Java_sp = src->_last_Java_sp;
     5.5    }
     5.6  
     5.7 -  // Always walkable
     5.8 -  bool walkable(void) { return true; }
     5.9 -  // Never any thing to do since we are always walkable and can find address of return addresses
    5.10 -  void make_walkable(JavaThread* thread) { }
    5.11 +  bool walkable(void)                            { return _last_Java_sp != NULL && _last_Java_pc != NULL; }
    5.12 +  void make_walkable(JavaThread* thread);
    5.13 +  void capture_last_Java_pc(void);
    5.14  
    5.15    intptr_t* last_Java_sp(void) const             { return _last_Java_sp; }
    5.16  
     6.1 --- a/src/cpu/x86/vm/macroAssembler_x86.cpp	Fri Jul 14 11:00:50 2017 -0700
     6.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.cpp	Fri Jul 14 11:35:22 2017 -0700
     6.3 @@ -748,8 +748,7 @@
     6.4    }
     6.5  }
     6.6  
     6.7 -void MacroAssembler::reset_last_Java_frame(bool clear_fp,
     6.8 -                                           bool clear_pc) {
     6.9 +void MacroAssembler::reset_last_Java_frame(bool clear_fp) {
    6.10    // we must set sp to zero to clear frame
    6.11    movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
    6.12    // must clear fp, so that compiled frames are not confused; it is
    6.13 @@ -758,9 +757,8 @@
    6.14      movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
    6.15    }
    6.16  
    6.17 -  if (clear_pc) {
    6.18 -    movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
    6.19 -  }
    6.20 +  // Always clear the pc because it could have been set by make_walkable()
    6.21 +  movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
    6.22  }
    6.23  
    6.24  void MacroAssembler::set_last_Java_frame(Register last_java_sp,
    6.25 @@ -2561,7 +2559,7 @@
    6.26    }
    6.27    // reset last Java frame
    6.28    // Only interpreter should have to clear fp
    6.29 -  reset_last_Java_frame(java_thread, true, false);
    6.30 +  reset_last_Java_frame(java_thread, true);
    6.31  
    6.32  #ifndef CC_INTERP
    6.33     // C++ interp handles this in the interpreter
    6.34 @@ -3808,7 +3806,7 @@
    6.35    pusha();
    6.36  }
    6.37  
    6.38 -void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp, bool clear_pc) {
    6.39 +void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp) {
    6.40    // determine java_thread register
    6.41    if (!java_thread->is_valid()) {
    6.42      java_thread = rdi;
    6.43 @@ -3820,8 +3818,8 @@
    6.44      movptr(Address(java_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
    6.45    }
    6.46  
    6.47 -  if (clear_pc)
    6.48 -    movptr(Address(java_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
    6.49 +  // Always clear the pc because it could have been set by make_walkable()
    6.50 +  movptr(Address(java_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
    6.51  
    6.52  }
    6.53  
     7.1 --- a/src/cpu/x86/vm/macroAssembler_x86.hpp	Fri Jul 14 11:00:50 2017 -0700
     7.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.hpp	Fri Jul 14 11:35:22 2017 -0700
     7.3 @@ -289,10 +289,10 @@
     7.4                             Register last_java_fp,
     7.5                             address last_java_pc);
     7.6  
     7.7 -  void reset_last_Java_frame(Register thread, bool clear_fp, bool clear_pc);
     7.8 +  void reset_last_Java_frame(Register thread, bool clear_fp);
     7.9  
    7.10    // thread in the default location (r15_thread on 64bit)
    7.11 -  void reset_last_Java_frame(bool clear_fp, bool clear_pc);
    7.12 +  void reset_last_Java_frame(bool clear_fp);
    7.13  
    7.14    // Stores
    7.15    void store_check(Register obj);                // store check for obj - register is destroyed afterwards
     8.1 --- a/src/cpu/x86/vm/runtime_x86_32.cpp	Fri Jul 14 11:00:50 2017 -0700
     8.2 +++ b/src/cpu/x86/vm/runtime_x86_32.cpp	Fri Jul 14 11:35:22 2017 -0700
     8.3 @@ -116,7 +116,7 @@
     8.4    // No registers to map, rbp is known implicitly
     8.5    oop_maps->add_gc_map( __ pc() - start,  new OopMap( framesize, 0 ));
     8.6    __ get_thread(rcx);
     8.7 -  __ reset_last_Java_frame(rcx, false, false);
     8.8 +  __ reset_last_Java_frame(rcx, false);
     8.9  
    8.10    // Restore callee-saved registers
    8.11    __ movptr(rbp, Address(rsp, rbp_off * wordSize));
     9.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Fri Jul 14 11:00:50 2017 -0700
     9.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Fri Jul 14 11:35:22 2017 -0700
     9.3 @@ -1333,7 +1333,7 @@
     9.4    __ increment(rsp, wordSize);
     9.5  
     9.6    __ get_thread(thread);
     9.7 -  __ reset_last_Java_frame(thread, false, true);
     9.8 +  __ reset_last_Java_frame(thread, false);
     9.9  
    9.10    save_or_restore_arguments(masm, stack_slots, total_in_args,
    9.11                              arg_save_area, NULL, in_regs, in_sig_bt);
    9.12 @@ -2251,7 +2251,7 @@
    9.13  
    9.14    // We can finally stop using that last_Java_frame we setup ages ago
    9.15  
    9.16 -  __ reset_last_Java_frame(thread, false, true);
    9.17 +  __ reset_last_Java_frame(thread, false);
    9.18  
    9.19    // Unpack oop result
    9.20    if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
    9.21 @@ -2951,7 +2951,7 @@
    9.22    __ pop(rcx);
    9.23  
    9.24    __ get_thread(rcx);
    9.25 -  __ reset_last_Java_frame(rcx, false, false);
    9.26 +  __ reset_last_Java_frame(rcx, false);
    9.27  
    9.28    // Load UnrollBlock into EDI
    9.29    __ mov(rdi, rax);
    9.30 @@ -3117,7 +3117,7 @@
    9.31    __ push(rax);
    9.32  
    9.33    __ get_thread(rcx);
    9.34 -  __ reset_last_Java_frame(rcx, false, false);
    9.35 +  __ reset_last_Java_frame(rcx, false);
    9.36  
    9.37    // Collect return values
    9.38    __ movptr(rax,Address(rsp, (RegisterSaver::raxOffset() + additional_words + 1)*wordSize));
    9.39 @@ -3219,7 +3219,7 @@
    9.40  
    9.41    __ get_thread(rcx);
    9.42  
    9.43 -  __ reset_last_Java_frame(rcx, false, false);
    9.44 +  __ reset_last_Java_frame(rcx, false);
    9.45  
    9.46    // Load UnrollBlock into EDI
    9.47    __ movptr(rdi, rax);
    9.48 @@ -3331,7 +3331,7 @@
    9.49    oop_maps->add_gc_map( __ pc()-start, new OopMap( framesize, 0 ) );
    9.50  
    9.51    __ get_thread(rdi);
    9.52 -  __ reset_last_Java_frame(rdi, true, false);
    9.53 +  __ reset_last_Java_frame(rdi, true);
    9.54  
    9.55    // Pop self-frame.
    9.56    __ leave();     // Epilog!
    9.57 @@ -3426,7 +3426,7 @@
    9.58  
    9.59    // Clear last_Java_sp again
    9.60    __ get_thread(java_thread);
    9.61 -  __ reset_last_Java_frame(java_thread, false, false);
    9.62 +  __ reset_last_Java_frame(java_thread, false);
    9.63  
    9.64    __ cmpptr(Address(java_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
    9.65    __ jcc(Assembler::equal, noException);
    9.66 @@ -3501,7 +3501,7 @@
    9.67    __ addptr(rsp, wordSize);
    9.68  
    9.69    // clear last_Java_sp
    9.70 -  __ reset_last_Java_frame(thread, true, false);
    9.71 +  __ reset_last_Java_frame(thread, true);
    9.72    // check for pending exceptions
    9.73    Label pending;
    9.74    __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
    10.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Fri Jul 14 11:00:50 2017 -0700
    10.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Fri Jul 14 11:35:22 2017 -0700
    10.3 @@ -1388,7 +1388,7 @@
    10.4    __ mov(rsp, r12); // restore sp
    10.5    __ reinit_heapbase();
    10.6  
    10.7 -  __ reset_last_Java_frame(false, true);
    10.8 +  __ reset_last_Java_frame(false);
    10.9  
   10.10    save_or_restore_arguments(masm, stack_slots, total_in_args,
   10.11                              arg_save_area, NULL, in_regs, in_sig_bt);
   10.12 @@ -2497,7 +2497,7 @@
   10.13      restore_native_result(masm, ret_type, stack_slots);
   10.14    }
   10.15  
   10.16 -  __ reset_last_Java_frame(false, true);
   10.17 +  __ reset_last_Java_frame(false);
   10.18  
   10.19    // Unpack oop result
   10.20    if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
   10.21 @@ -3435,7 +3435,7 @@
   10.22    // find any register it might need.
   10.23    oop_maps->add_gc_map(__ pc() - start, map);
   10.24  
   10.25 -  __ reset_last_Java_frame(false, false);
   10.26 +  __ reset_last_Java_frame(false);
   10.27  
   10.28    // Load UnrollBlock* into rdi
   10.29    __ mov(rdi, rax);
   10.30 @@ -3592,7 +3592,7 @@
   10.31                         new OopMap( frame_size_in_words, 0 ));
   10.32  
   10.33    // Clear fp AND pc
   10.34 -  __ reset_last_Java_frame(true, true);
   10.35 +  __ reset_last_Java_frame(true);
   10.36  
   10.37    // Collect return values
   10.38    __ movdbl(xmm0, Address(rsp, RegisterSaver::xmm0_offset_in_bytes()));
   10.39 @@ -3662,7 +3662,7 @@
   10.40  
   10.41    oop_maps->add_gc_map(__ pc() - start, map);
   10.42  
   10.43 -  __ reset_last_Java_frame(false, false);
   10.44 +  __ reset_last_Java_frame(false);
   10.45  
   10.46    // Load UnrollBlock* into rdi
   10.47    __ mov(rdi, rax);
   10.48 @@ -3775,7 +3775,7 @@
   10.49    oop_maps->add_gc_map(the_pc - start, new OopMap(SimpleRuntimeFrame::framesize, 0));
   10.50  
   10.51    // Clear fp AND pc
   10.52 -  __ reset_last_Java_frame(true, true);
   10.53 +  __ reset_last_Java_frame(true);
   10.54  
   10.55    // Pop self-frame.
   10.56    __ leave();                 // Epilog
   10.57 @@ -3858,7 +3858,7 @@
   10.58  
   10.59    Label noException;
   10.60  
   10.61 -  __ reset_last_Java_frame(false, false);
   10.62 +  __ reset_last_Java_frame(false);
   10.63  
   10.64    __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
   10.65    __ jcc(Assembler::equal, noException);
   10.66 @@ -3928,7 +3928,7 @@
   10.67    // rax contains the address we are going to jump to assuming no exception got installed
   10.68  
   10.69    // clear last_Java_sp
   10.70 -  __ reset_last_Java_frame(false, false);
   10.71 +  __ reset_last_Java_frame(false);
   10.72    // check for pending exceptions
   10.73    Label pending;
   10.74    __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
   10.75 @@ -4309,7 +4309,7 @@
   10.76  
   10.77    oop_maps->add_gc_map(the_pc - start, new OopMap(SimpleRuntimeFrame::framesize, 0));
   10.78  
   10.79 -  __ reset_last_Java_frame(false, true);
   10.80 +  __ reset_last_Java_frame(false);
   10.81  
   10.82    // Restore callee-saved registers
   10.83  
    11.1 --- a/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Fri Jul 14 11:00:50 2017 -0700
    11.2 +++ b/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Fri Jul 14 11:35:22 2017 -0700
    11.3 @@ -2901,7 +2901,7 @@
    11.4      // however can use the register value directly if it is callee saved.
    11.5      __ get_thread(java_thread);
    11.6  
    11.7 -    __ reset_last_Java_frame(java_thread, true, false);
    11.8 +    __ reset_last_Java_frame(java_thread, true);
    11.9  
   11.10      __ leave(); // required for proper stackwalking of RuntimeStub frame
   11.11  
    12.1 --- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Fri Jul 14 11:00:50 2017 -0700
    12.2 +++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Fri Jul 14 11:35:22 2017 -0700
    12.3 @@ -3923,7 +3923,7 @@
    12.4  
    12.5      oop_maps->add_gc_map(the_pc - start, map);
    12.6  
    12.7 -    __ reset_last_Java_frame(true, true);
    12.8 +    __ reset_last_Java_frame(true);
    12.9  
   12.10      __ leave(); // required for proper stackwalking of RuntimeStub frame
   12.11  
    13.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Fri Jul 14 11:00:50 2017 -0700
    13.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Fri Jul 14 11:35:22 2017 -0700
    13.3 @@ -1289,7 +1289,7 @@
    13.4    // change thread state
    13.5    __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java);
    13.6  
    13.7 -  __ reset_last_Java_frame(thread, true, true);
    13.8 +  __ reset_last_Java_frame(thread, true);
    13.9  
   13.10    // reset handle block
   13.11    __ movptr(t, Address(thread, JavaThread::active_handles_offset()));
   13.12 @@ -1819,7 +1819,7 @@
   13.13    __ set_last_Java_frame(thread, noreg, rbp, __ pc());
   13.14    __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), thread, rax, rbx);
   13.15    __ get_thread(thread);
   13.16 -  __ reset_last_Java_frame(thread, true, true);
   13.17 +  __ reset_last_Java_frame(thread, true);
   13.18    // Restore the last_sp and null it out
   13.19    __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize));
   13.20    __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
    14.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Fri Jul 14 11:00:50 2017 -0700
    14.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Fri Jul 14 11:35:22 2017 -0700
    14.3 @@ -1262,7 +1262,7 @@
    14.4    __ movl(Address(r15_thread, JavaThread::thread_state_offset()), _thread_in_Java);
    14.5  
    14.6    // reset_last_Java_frame
    14.7 -  __ reset_last_Java_frame(true, true);
    14.8 +  __ reset_last_Java_frame(r15_thread, true);
    14.9  
   14.10    // reset handle block
   14.11    __ movptr(t, Address(r15_thread, JavaThread::active_handles_offset()));
   14.12 @@ -1837,7 +1837,7 @@
   14.13    // PC must point into interpreter here
   14.14    __ set_last_Java_frame(noreg, rbp, __ pc());
   14.15    __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), r15_thread, c_rarg1, c_rarg2);
   14.16 -  __ reset_last_Java_frame(true, true);
   14.17 +  __ reset_last_Java_frame(r15_thread, true);
   14.18    // Restore the last_sp and null it out
   14.19    __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize));
   14.20    __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);
    15.1 --- a/src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp	Fri Jul 14 11:00:50 2017 -0700
    15.2 +++ b/src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp	Fri Jul 14 11:35:22 2017 -0700
    15.3 @@ -44,7 +44,7 @@
    15.4  
    15.5    // If we have a last_Java_frame, then we should use it even if
    15.6    // isInJava == true.  It should be more reliable than ucontext info.
    15.7 -  if (jt->has_last_Java_frame()) {
    15.8 +  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
    15.9      *fr_addr = jt->pd_last_frame();
   15.10      return true;
   15.11    }
    16.1 --- a/src/os_cpu/bsd_x86/vm/thread_bsd_x86.hpp	Fri Jul 14 11:00:50 2017 -0700
    16.2 +++ b/src/os_cpu/bsd_x86/vm/thread_bsd_x86.hpp	Fri Jul 14 11:35:22 2017 -0700
    16.3 @@ -32,12 +32,8 @@
    16.4  
    16.5    frame pd_last_frame() {
    16.6      assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
    16.7 -    if (_anchor.last_Java_pc() != NULL) {
    16.8 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
    16.9 -    } else {
   16.10 -      // This will pick up pc from sp
   16.11 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());
   16.12 -    }
   16.13 +    assert(_anchor.last_Java_pc() != NULL, "not walkable");
   16.14 +    return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
   16.15    }
   16.16  
   16.17   public:
    17.1 --- a/src/os_cpu/linux_x86/vm/thread_linux_x86.cpp	Fri Jul 14 11:00:50 2017 -0700
    17.2 +++ b/src/os_cpu/linux_x86/vm/thread_linux_x86.cpp	Fri Jul 14 11:35:22 2017 -0700
    17.3 @@ -45,7 +45,7 @@
    17.4  
    17.5    // If we have a last_Java_frame, then we should use it even if
    17.6    // isInJava == true.  It should be more reliable than ucontext info.
    17.7 -  if (jt->has_last_Java_frame()) {
    17.8 +  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
    17.9      *fr_addr = jt->pd_last_frame();
   17.10      return true;
   17.11    }
    18.1 --- a/src/os_cpu/linux_x86/vm/thread_linux_x86.hpp	Fri Jul 14 11:00:50 2017 -0700
    18.2 +++ b/src/os_cpu/linux_x86/vm/thread_linux_x86.hpp	Fri Jul 14 11:35:22 2017 -0700
    18.3 @@ -32,12 +32,8 @@
    18.4  
    18.5    frame pd_last_frame() {
    18.6      assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
    18.7 -    if (_anchor.last_Java_pc() != NULL) {
    18.8 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
    18.9 -    } else {
   18.10 -      // This will pick up pc from sp
   18.11 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());
   18.12 -    }
   18.13 +    assert(_anchor.last_Java_pc() != NULL, "not walkable");
   18.14 +    return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
   18.15    }
   18.16  
   18.17   public:
    19.1 --- a/src/os_cpu/solaris_x86/vm/thread_solaris_x86.cpp	Fri Jul 14 11:00:50 2017 -0700
    19.2 +++ b/src/os_cpu/solaris_x86/vm/thread_solaris_x86.cpp	Fri Jul 14 11:35:22 2017 -0700
    19.3 @@ -44,9 +44,8 @@
    19.4    assert(this->is_Java_thread(), "must be JavaThread");
    19.5    JavaThread* jt = (JavaThread *)this;
    19.6  
    19.7 -  // last_Java_frame is always walkable and safe use it if we have it
    19.8 -
    19.9 -  if (jt->has_last_Java_frame()) {
   19.10 +  // There is small window where last_Java_frame is not walkable or safe
   19.11 +  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
   19.12      *fr_addr = jt->pd_last_frame();
   19.13      return true;
   19.14    }
    20.1 --- a/src/os_cpu/solaris_x86/vm/thread_solaris_x86.hpp	Fri Jul 14 11:00:50 2017 -0700
    20.2 +++ b/src/os_cpu/solaris_x86/vm/thread_solaris_x86.hpp	Fri Jul 14 11:35:22 2017 -0700
    20.3 @@ -30,12 +30,8 @@
    20.4  
    20.5    frame pd_last_frame() {
    20.6      assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
    20.7 -    if (_anchor.last_Java_pc() != NULL) {
    20.8 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
    20.9 -    } else {
   20.10 -      // This will pick up pc from sp
   20.11 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());
   20.12 -    }
   20.13 +    assert(_anchor.last_Java_pc() != NULL, "not walkable");
   20.14 +    return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
   20.15    }
   20.16  
   20.17   public:
    21.1 --- a/src/os_cpu/windows_x86/vm/thread_windows_x86.cpp	Fri Jul 14 11:00:50 2017 -0700
    21.2 +++ b/src/os_cpu/windows_x86/vm/thread_windows_x86.cpp	Fri Jul 14 11:35:22 2017 -0700
    21.3 @@ -47,7 +47,7 @@
    21.4  
    21.5    // If we have a last_Java_frame, then we should use it even if
    21.6    // isInJava == true.  It should be more reliable than CONTEXT info.
    21.7 -  if (jt->has_last_Java_frame()) {
    21.8 +  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
    21.9      *fr_addr = jt->pd_last_frame();
   21.10      return true;
   21.11    }
    22.1 --- a/src/os_cpu/windows_x86/vm/thread_windows_x86.hpp	Fri Jul 14 11:00:50 2017 -0700
    22.2 +++ b/src/os_cpu/windows_x86/vm/thread_windows_x86.hpp	Fri Jul 14 11:35:22 2017 -0700
    22.3 @@ -32,12 +32,8 @@
    22.4  
    22.5    frame pd_last_frame() {
    22.6      assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
    22.7 -    if (_anchor.last_Java_pc() != NULL) {
    22.8 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
    22.9 -    } else {
   22.10 -      // This will pick up pc from sp
   22.11 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());
   22.12 -    }
   22.13 +    assert(_anchor.last_Java_pc() != NULL, "not walkable");
   22.14 +    return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
   22.15    }
   22.16  
   22.17   public:
    23.1 --- a/src/share/vm/services/lowMemoryDetector.cpp	Fri Jul 14 11:00:50 2017 -0700
    23.2 +++ b/src/share/vm/services/lowMemoryDetector.cpp	Fri Jul 14 11:35:22 2017 -0700
    23.3 @@ -1,5 +1,5 @@
    23.4  /*
    23.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
    23.6 + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
    23.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.8   *
    23.9   * This code is free software; you can redistribute it and/or modify it
   23.10 @@ -298,19 +298,41 @@
   23.11      Klass* k = Management::sun_management_Sensor_klass(CHECK);
   23.12      instanceKlassHandle sensorKlass (THREAD, k);
   23.13      Handle sensor_h(THREAD, _sensor_obj);
   23.14 -    Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, CHECK);
   23.15 +
   23.16 +    Symbol* trigger_method_signature;
   23.17  
   23.18      JavaValue result(T_VOID);
   23.19      JavaCallArguments args(sensor_h);
   23.20      args.push_int((int) count);
   23.21 -    args.push_oop(usage_h);
   23.22 +
   23.23 +    Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, THREAD);
   23.24 +    // Call Sensor::trigger(int, MemoryUsage) to send notification to listeners.
   23.25 +    // When OOME occurs and fails to allocate MemoryUsage object, call
   23.26 +    // Sensor::trigger(int) instead.  The pending request will be processed
   23.27 +    // but no notification will be sent.
   23.28 +    if (HAS_PENDING_EXCEPTION) {
   23.29 +       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
   23.30 +       CLEAR_PENDING_EXCEPTION;
   23.31 +       trigger_method_signature = vmSymbols::int_void_signature();
   23.32 +    } else {
   23.33 +       trigger_method_signature = vmSymbols::trigger_method_signature();
   23.34 +       args.push_oop(usage_h);
   23.35 +    }
   23.36  
   23.37      JavaCalls::call_virtual(&result,
   23.38                              sensorKlass,
   23.39                              vmSymbols::trigger_name(),
   23.40 -                            vmSymbols::trigger_method_signature(),
   23.41 +                            trigger_method_signature,
   23.42                              &args,
   23.43 -                            CHECK);
   23.44 +                            THREAD);
   23.45 +
   23.46 +    if (HAS_PENDING_EXCEPTION) {
   23.47 +       // We just clear the OOM pending exception that we might have encountered
   23.48 +       // in Java's tiggerAction(), and continue with updating the counters since
   23.49 +       // the Java counters have been updated too.
   23.50 +       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
   23.51 +       CLEAR_PENDING_EXCEPTION;
   23.52 +     }
   23.53    }
   23.54  
   23.55    {

mercurial