Skip to content

Commit 8276685

Browse files
author
asaha
committed
Merge
2 parents b9149a2 + b9bdf78 commit 8276685

23 files changed

+107
-81
lines changed

.hgtags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,8 @@ d6e7c7d2c6f69906b4cb643a6813eccba0de988f jdk8u141-b12
985985
df6af363337eff5b22ae7940b0981231fdf5dfb4 jdk8u141-b13
986986
3a1543e089c32592be9c201c6e021295fbf5fdc1 jdk8u141-b14
987987
23f1790147d838ddb1133cc79dc08e7c9ba5ab44 jdk8u141-b15
988+
9ffa0d7ed932045a0b4ceb095fb52444eed39c1b jdk8u141-b31
989+
ae8cae699f62b845703c891e0e7633e2089a3ec4 jdk8u141-b32
988990
2d5100bddeb80cf767485b787fc3051311e3d7b9 jdk8u151-b00
989991
596b584c68b73ec635347807571463580deb955f jdk8u151-b01
990992
1f6f436360d5cd375b806aec1c78abb8fcb4e5f6 jdk8u151-b02

src/cpu/x86/vm/c1_Runtime1_x86.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, addre
9898
}
9999
pop(rax);
100100
#endif
101-
reset_last_Java_frame(thread, true, align_stack);
101+
reset_last_Java_frame(thread, true);
102102

103103
// discard thread and arguments
104104
NOT_LP64(addptr(rsp, num_rt_args()*BytesPerWord));
@@ -882,7 +882,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) {
882882
}
883883
__ pop(rax);
884884
#endif
885-
__ reset_last_Java_frame(thread, true, false);
885+
__ reset_last_Java_frame(thread, true);
886886
#ifndef _LP64
887887
__ pop(rcx); // discard thread arg
888888
__ pop(rcx); // discard dummy

src/cpu/x86/vm/frame_x86.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,16 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const {
370370
JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
371371
assert(!entry_frame_is_first(), "next Java fp must be non zero");
372372
assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
373+
// Since we are walking the stack now this nested anchor is obviously walkable
374+
// even if it wasn't when it was stacked.
375+
if (!jfa->walkable()) {
376+
// Capture _last_Java_pc (if needed) and mark anchor walkable.
377+
jfa->capture_last_Java_pc();
378+
}
373379
map->clear();
374380
assert(map->include_argument_oops(), "should be set by clear");
375-
if (jfa->last_Java_pc() != NULL ) {
376-
frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
377-
return fr;
378-
}
379-
frame fr(jfa->last_Java_sp(), jfa->last_Java_fp());
381+
assert(jfa->last_Java_pc() != NULL, "not walkable");
382+
frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
380383
return fr;
381384
}
382385

@@ -714,3 +717,21 @@ frame::frame(void* sp, void* fp, void* pc) {
714717
init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
715718
}
716719
#endif
720+
721+
void JavaFrameAnchor::make_walkable(JavaThread* thread) {
722+
// last frame set?
723+
if (last_Java_sp() == NULL) return;
724+
// already walkable?
725+
if (walkable()) return;
726+
assert(Thread::current() == (Thread*)thread, "not current thread");
727+
assert(last_Java_sp() != NULL, "not called from Java code?");
728+
assert(last_Java_pc() == NULL, "already walkable");
729+
capture_last_Java_pc();
730+
assert(walkable(), "something went wrong");
731+
}
732+
733+
void JavaFrameAnchor::capture_last_Java_pc() {
734+
assert(_last_Java_sp != NULL, "no last frame set");
735+
assert(_last_Java_pc == NULL, "already walkable");
736+
_last_Java_pc = (address)_last_Java_sp[-1];
737+
}

src/cpu/x86/vm/frame_x86.inline.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ inline frame::frame(intptr_t* sp, intptr_t* fp) {
9696
// call a specialized frame constructor instead of this one.
9797
// Then we could use the assert below. However this assert is of somewhat dubious
9898
// value.
99+
// UPDATE: this constructor is only used by trace_method_handle_stub() now.
99100
// assert(_pc != NULL, "no pc?");
100101

101102
_cb = CodeCache::find_blob(_pc);

src/cpu/x86/vm/javaFrameAnchor_x86.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@
6262
_last_Java_sp = src->_last_Java_sp;
6363
}
6464

65-
// Always walkable
66-
bool walkable(void) { return true; }
67-
// Never any thing to do since we are always walkable and can find address of return addresses
68-
void make_walkable(JavaThread* thread) { }
65+
bool walkable(void) { return _last_Java_sp != NULL && _last_Java_pc != NULL; }
66+
void make_walkable(JavaThread* thread);
67+
void capture_last_Java_pc(void);
6968

7069
intptr_t* last_Java_sp(void) const { return _last_Java_sp; }
7170

src/cpu/x86/vm/macroAssembler_x86.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,7 @@ void MacroAssembler::pushptr(AddressLiteral src) {
748748
}
749749
}
750750

751-
void MacroAssembler::reset_last_Java_frame(bool clear_fp,
752-
bool clear_pc) {
751+
void MacroAssembler::reset_last_Java_frame(bool clear_fp) {
753752
// we must set sp to zero to clear frame
754753
movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
755754
// must clear fp, so that compiled frames are not confused; it is
@@ -758,9 +757,8 @@ void MacroAssembler::reset_last_Java_frame(bool clear_fp,
758757
movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
759758
}
760759

761-
if (clear_pc) {
762-
movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
763-
}
760+
// Always clear the pc because it could have been set by make_walkable()
761+
movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
764762
}
765763

766764
void MacroAssembler::set_last_Java_frame(Register last_java_sp,
@@ -2561,7 +2559,7 @@ void MacroAssembler::call_VM_base(Register oop_result,
25612559
}
25622560
// reset last Java frame
25632561
// Only interpreter should have to clear fp
2564-
reset_last_Java_frame(java_thread, true, false);
2562+
reset_last_Java_frame(java_thread, true);
25652563

25662564
#ifndef CC_INTERP
25672565
// C++ interp handles this in the interpreter
@@ -3808,7 +3806,7 @@ void MacroAssembler::push_IU_state() {
38083806
pusha();
38093807
}
38103808

3811-
void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp, bool clear_pc) {
3809+
void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp) {
38123810
// determine java_thread register
38133811
if (!java_thread->is_valid()) {
38143812
java_thread = rdi;
@@ -3820,8 +3818,8 @@ void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp,
38203818
movptr(Address(java_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
38213819
}
38223820

3823-
if (clear_pc)
3824-
movptr(Address(java_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
3821+
// Always clear the pc because it could have been set by make_walkable()
3822+
movptr(Address(java_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
38253823

38263824
}
38273825

src/cpu/x86/vm/macroAssembler_x86.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ class MacroAssembler: public Assembler {
289289
Register last_java_fp,
290290
address last_java_pc);
291291

292-
void reset_last_Java_frame(Register thread, bool clear_fp, bool clear_pc);
292+
void reset_last_Java_frame(Register thread, bool clear_fp);
293293

294294
// thread in the default location (r15_thread on 64bit)
295-
void reset_last_Java_frame(bool clear_fp, bool clear_pc);
295+
void reset_last_Java_frame(bool clear_fp);
296296

297297
// Stores
298298
void store_check(Register obj); // store check for obj - register is destroyed afterwards

src/cpu/x86/vm/runtime_x86_32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void OptoRuntime::generate_exception_blob() {
116116
// No registers to map, rbp is known implicitly
117117
oop_maps->add_gc_map( __ pc() - start, new OopMap( framesize, 0 ));
118118
__ get_thread(rcx);
119-
__ reset_last_Java_frame(rcx, false, false);
119+
__ reset_last_Java_frame(rcx, false);
120120

121121
// Restore callee-saved registers
122122
__ movptr(rbp, Address(rsp, rbp_off * wordSize));

src/cpu/x86/vm/sharedRuntime_x86_32.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ static void check_needs_gc_for_critical_native(MacroAssembler* masm,
13331333
__ increment(rsp, wordSize);
13341334

13351335
__ get_thread(thread);
1336-
__ reset_last_Java_frame(thread, false, true);
1336+
__ reset_last_Java_frame(thread, false);
13371337

13381338
save_or_restore_arguments(masm, stack_slots, total_in_args,
13391339
arg_save_area, NULL, in_regs, in_sig_bt);
@@ -2251,7 +2251,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
22512251

22522252
// We can finally stop using that last_Java_frame we setup ages ago
22532253

2254-
__ reset_last_Java_frame(thread, false, true);
2254+
__ reset_last_Java_frame(thread, false);
22552255

22562256
// Unpack oop result
22572257
if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
@@ -2951,7 +2951,7 @@ void SharedRuntime::generate_deopt_blob() {
29512951
__ pop(rcx);
29522952

29532953
__ get_thread(rcx);
2954-
__ reset_last_Java_frame(rcx, false, false);
2954+
__ reset_last_Java_frame(rcx, false);
29552955

29562956
// Load UnrollBlock into EDI
29572957
__ mov(rdi, rax);
@@ -3117,7 +3117,7 @@ void SharedRuntime::generate_deopt_blob() {
31173117
__ push(rax);
31183118

31193119
__ get_thread(rcx);
3120-
__ reset_last_Java_frame(rcx, false, false);
3120+
__ reset_last_Java_frame(rcx, false);
31213121

31223122
// Collect return values
31233123
__ movptr(rax,Address(rsp, (RegisterSaver::raxOffset() + additional_words + 1)*wordSize));
@@ -3219,7 +3219,7 @@ void SharedRuntime::generate_uncommon_trap_blob() {
32193219

32203220
__ get_thread(rcx);
32213221

3222-
__ reset_last_Java_frame(rcx, false, false);
3222+
__ reset_last_Java_frame(rcx, false);
32233223

32243224
// Load UnrollBlock into EDI
32253225
__ movptr(rdi, rax);
@@ -3331,7 +3331,7 @@ void SharedRuntime::generate_uncommon_trap_blob() {
33313331
oop_maps->add_gc_map( __ pc()-start, new OopMap( framesize, 0 ) );
33323332

33333333
__ get_thread(rdi);
3334-
__ reset_last_Java_frame(rdi, true, false);
3334+
__ reset_last_Java_frame(rdi, true);
33353335

33363336
// Pop self-frame.
33373337
__ leave(); // Epilog!
@@ -3426,7 +3426,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
34263426

34273427
// Clear last_Java_sp again
34283428
__ get_thread(java_thread);
3429-
__ reset_last_Java_frame(java_thread, false, false);
3429+
__ reset_last_Java_frame(java_thread, false);
34303430

34313431
__ cmpptr(Address(java_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
34323432
__ jcc(Assembler::equal, noException);
@@ -3501,7 +3501,7 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha
35013501
__ addptr(rsp, wordSize);
35023502

35033503
// clear last_Java_sp
3504-
__ reset_last_Java_frame(thread, true, false);
3504+
__ reset_last_Java_frame(thread, true);
35053505
// check for pending exceptions
35063506
Label pending;
35073507
__ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);

src/cpu/x86/vm/sharedRuntime_x86_64.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ static void check_needs_gc_for_critical_native(MacroAssembler* masm,
13881388
__ mov(rsp, r12); // restore sp
13891389
__ reinit_heapbase();
13901390

1391-
__ reset_last_Java_frame(false, true);
1391+
__ reset_last_Java_frame(false);
13921392

13931393
save_or_restore_arguments(masm, stack_slots, total_in_args,
13941394
arg_save_area, NULL, in_regs, in_sig_bt);
@@ -2497,7 +2497,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
24972497
restore_native_result(masm, ret_type, stack_slots);
24982498
}
24992499

2500-
__ reset_last_Java_frame(false, true);
2500+
__ reset_last_Java_frame(false);
25012501

25022502
// Unpack oop result
25032503
if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
@@ -3435,7 +3435,7 @@ void SharedRuntime::generate_deopt_blob() {
34353435
// find any register it might need.
34363436
oop_maps->add_gc_map(__ pc() - start, map);
34373437

3438-
__ reset_last_Java_frame(false, false);
3438+
__ reset_last_Java_frame(false);
34393439

34403440
// Load UnrollBlock* into rdi
34413441
__ mov(rdi, rax);
@@ -3592,7 +3592,7 @@ void SharedRuntime::generate_deopt_blob() {
35923592
new OopMap( frame_size_in_words, 0 ));
35933593

35943594
// Clear fp AND pc
3595-
__ reset_last_Java_frame(true, true);
3595+
__ reset_last_Java_frame(true);
35963596

35973597
// Collect return values
35983598
__ movdbl(xmm0, Address(rsp, RegisterSaver::xmm0_offset_in_bytes()));
@@ -3662,7 +3662,7 @@ void SharedRuntime::generate_uncommon_trap_blob() {
36623662

36633663
oop_maps->add_gc_map(__ pc() - start, map);
36643664

3665-
__ reset_last_Java_frame(false, false);
3665+
__ reset_last_Java_frame(false);
36663666

36673667
// Load UnrollBlock* into rdi
36683668
__ mov(rdi, rax);
@@ -3775,7 +3775,7 @@ void SharedRuntime::generate_uncommon_trap_blob() {
37753775
oop_maps->add_gc_map(the_pc - start, new OopMap(SimpleRuntimeFrame::framesize, 0));
37763776

37773777
// Clear fp AND pc
3778-
__ reset_last_Java_frame(true, true);
3778+
__ reset_last_Java_frame(true);
37793779

37803780
// Pop self-frame.
37813781
__ leave(); // Epilog
@@ -3858,7 +3858,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
38583858

38593859
Label noException;
38603860

3861-
__ reset_last_Java_frame(false, false);
3861+
__ reset_last_Java_frame(false);
38623862

38633863
__ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
38643864
__ jcc(Assembler::equal, noException);
@@ -3928,7 +3928,7 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha
39283928
// rax contains the address we are going to jump to assuming no exception got installed
39293929

39303930
// clear last_Java_sp
3931-
__ reset_last_Java_frame(false, false);
3931+
__ reset_last_Java_frame(false);
39323932
// check for pending exceptions
39333933
Label pending;
39343934
__ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
@@ -4309,7 +4309,7 @@ void OptoRuntime::generate_exception_blob() {
43094309

43104310
oop_maps->add_gc_map(the_pc - start, new OopMap(SimpleRuntimeFrame::framesize, 0));
43114311

4312-
__ reset_last_Java_frame(false, true);
4312+
__ reset_last_Java_frame(false);
43134313

43144314
// Restore callee-saved registers
43154315

0 commit comments

Comments
 (0)