Tue, 09 Mar 2010 23:57:36 -0800
Merge
1.1 --- a/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp Tue Mar 09 11:02:39 2010 -0800 1.2 +++ b/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp Tue Mar 09 23:57:36 2010 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -377,6 +377,16 @@ 1.11 1.12 } 1.13 1.14 + 1.15 +void DeoptimizeStub::emit_code(LIR_Assembler* ce) { 1.16 + __ bind(_entry); 1.17 + __ call(SharedRuntime::deopt_blob()->unpack_with_reexecution()); 1.18 + __ delayed()->nop(); 1.19 + ce->add_call_info_here(_info); 1.20 + debug_only(__ should_not_reach_here()); 1.21 +} 1.22 + 1.23 + 1.24 void ArrayCopyStub::emit_code(LIR_Assembler* ce) { 1.25 //---------------slow case: call to native----------------- 1.26 __ bind(_entry);
2.1 --- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Tue Mar 09 11:02:39 2010 -0800 2.2 +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Tue Mar 09 23:57:36 2010 -0800 2.3 @@ -378,12 +378,7 @@ 2.4 2.5 int offset = code_offset(); 2.6 2.7 - if (compilation()->has_exception_handlers() || compilation()->env()->jvmti_can_post_on_exceptions()) { 2.8 - __ call(Runtime1::entry_for(Runtime1::handle_exception_id), relocInfo::runtime_call_type); 2.9 - __ delayed()->nop(); 2.10 - } 2.11 - 2.12 - __ call(Runtime1::entry_for(Runtime1::unwind_exception_id), relocInfo::runtime_call_type); 2.13 + __ call(Runtime1::entry_for(Runtime1::handle_exception_id), relocInfo::runtime_call_type); 2.14 __ delayed()->nop(); 2.15 debug_only(__ stop("should have gone to the caller");) 2.16 assert(code_offset() - offset <= exception_handler_size, "overflow"); 2.17 @@ -685,29 +680,29 @@ 2.18 } 2.19 2.20 2.21 -void LIR_Assembler::call(address entry, relocInfo::relocType rtype, CodeEmitInfo* info) { 2.22 - __ call(entry, rtype); 2.23 +void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) { 2.24 + __ call(op->addr(), rtype); 2.25 // the peephole pass fills the delay slot 2.26 } 2.27 2.28 2.29 -void LIR_Assembler::ic_call(address entry, CodeEmitInfo* info) { 2.30 +void LIR_Assembler::ic_call(LIR_OpJavaCall* op) { 2.31 RelocationHolder rspec = virtual_call_Relocation::spec(pc()); 2.32 __ set_oop((jobject)Universe::non_oop_word(), G5_inline_cache_reg); 2.33 __ relocate(rspec); 2.34 - __ call(entry, relocInfo::none); 2.35 + __ call(op->addr(), relocInfo::none); 2.36 // the peephole pass fills the delay slot 2.37 } 2.38 2.39 2.40 -void LIR_Assembler::vtable_call(int vtable_offset, CodeEmitInfo* info) { 2.41 - add_debug_info_for_null_check_here(info); 2.42 +void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) { 2.43 + add_debug_info_for_null_check_here(op->info()); 2.44 __ ld_ptr(O0, oopDesc::klass_offset_in_bytes(), G3_scratch); 2.45 - if (__ is_simm13(vtable_offset) ) { 2.46 - __ ld_ptr(G3_scratch, vtable_offset, G5_method); 2.47 + if (__ is_simm13(op->vtable_offset())) { 2.48 + __ ld_ptr(G3_scratch, op->vtable_offset(), G5_method); 2.49 } else { 2.50 // This will generate 2 instructions 2.51 - __ set(vtable_offset, G5_method); 2.52 + __ set(op->vtable_offset(), G5_method); 2.53 // ld_ptr, set_hi, set 2.54 __ ld_ptr(G3_scratch, G5_method, G5_method); 2.55 } 2.56 @@ -717,6 +712,16 @@ 2.57 } 2.58 2.59 2.60 +void LIR_Assembler::preserve_SP() { 2.61 + Unimplemented(); 2.62 +} 2.63 + 2.64 + 2.65 +void LIR_Assembler::restore_SP() { 2.66 + Unimplemented(); 2.67 +} 2.68 + 2.69 + 2.70 // load with 32-bit displacement 2.71 int LIR_Assembler::load(Register s, int disp, Register d, BasicType ld_type, CodeEmitInfo *info) { 2.72 int load_offset = code_offset();
3.1 --- a/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp Tue Mar 09 11:02:39 2010 -0800 3.2 +++ b/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp Tue Mar 09 23:57:36 2010 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. 3.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -42,17 +42,6 @@ 3.11 } 3.12 3.13 3.14 -void C1_MacroAssembler::method_exit(bool restore_frame) { 3.15 - // this code must be structured this way so that the return 3.16 - // instruction can be a safepoint. 3.17 - if (restore_frame) { 3.18 - restore(); 3.19 - } 3.20 - retl(); 3.21 - delayed()->nop(); 3.22 -} 3.23 - 3.24 - 3.25 void C1_MacroAssembler::explicit_null_check(Register base) { 3.26 Unimplemented(); 3.27 }
4.1 --- a/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp Tue Mar 09 11:02:39 2010 -0800 4.2 +++ b/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp Tue Mar 09 23:57:36 2010 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. 4.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -677,7 +677,7 @@ 4.11 __ add(I7, frame::pc_return_offset, Oissuing_pc->after_save()); 4.12 4.13 __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), 4.14 - Oissuing_pc->after_save()); 4.15 + G2_thread, Oissuing_pc->after_save()); 4.16 __ verify_not_null_oop(Oexception->after_save()); 4.17 __ jmp(O0, 0); 4.18 __ delayed()->restore(); 4.19 @@ -985,7 +985,6 @@ 4.20 4.21 void Runtime1::generate_handle_exception(StubAssembler* sasm, OopMapSet* oop_maps, OopMap* oop_map, bool) { 4.22 Label no_deopt; 4.23 - Label no_handler; 4.24 4.25 __ verify_not_null_oop(Oexception); 4.26 4.27 @@ -1003,9 +1002,14 @@ 4.28 // whether it had a handler or not we will deoptimize 4.29 // by entering the deopt blob with a pending exception. 4.30 4.31 +#ifdef ASSERT 4.32 + Label done; 4.33 __ tst(O0); 4.34 - __ br(Assembler::zero, false, Assembler::pn, no_handler); 4.35 + __ br(Assembler::notZero, false, Assembler::pn, done); 4.36 __ delayed()->nop(); 4.37 + __ stop("should have found address"); 4.38 + __ bind(done); 4.39 +#endif 4.40 4.41 // restore the registers that were saved at the beginning and jump to the exception handler. 4.42 restore_live_registers(sasm); 4.43 @@ -1013,20 +1017,6 @@ 4.44 __ jmp(O0, 0); 4.45 __ delayed()->restore(); 4.46 4.47 - __ bind(no_handler); 4.48 - __ mov(L0, I7); // restore return address 4.49 - 4.50 - // restore exception oop 4.51 - __ ld_ptr(G2_thread, in_bytes(JavaThread::exception_oop_offset()), Oexception->after_save()); 4.52 - __ st_ptr(G0, G2_thread, in_bytes(JavaThread::exception_oop_offset())); 4.53 - 4.54 - __ restore(); 4.55 - 4.56 - AddressLiteral exc(Runtime1::entry_for(Runtime1::unwind_exception_id)); 4.57 - __ jump_to(exc, G4); 4.58 - __ delayed()->nop(); 4.59 - 4.60 - 4.61 oop_maps->add_gc_map(call_offset, oop_map); 4.62 } 4.63
5.1 --- a/src/cpu/sparc/vm/interp_masm_sparc.cpp Tue Mar 09 11:02:39 2010 -0800 5.2 +++ b/src/cpu/sparc/vm/interp_masm_sparc.cpp Tue Mar 09 23:57:36 2010 -0800 5.3 @@ -244,9 +244,10 @@ 5.4 } 5.5 5.6 5.7 -void InterpreterMacroAssembler::super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1) { 5.8 +void InterpreterMacroAssembler::super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2) { 5.9 mov(arg_1, O0); 5.10 - MacroAssembler::call_VM_leaf_base(thread_cache, entry_point, 1); 5.11 + mov(arg_2, O1); 5.12 + MacroAssembler::call_VM_leaf_base(thread_cache, entry_point, 2); 5.13 } 5.14 #endif /* CC_INTERP */ 5.15
6.1 --- a/src/cpu/sparc/vm/interp_masm_sparc.hpp Tue Mar 09 11:02:39 2010 -0800 6.2 +++ b/src/cpu/sparc/vm/interp_masm_sparc.hpp Tue Mar 09 23:57:36 2010 -0800 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. 6.6 + * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -121,7 +121,7 @@ 6.11 bool check_exception = true); 6.12 6.13 #ifndef CC_INTERP 6.14 - void super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1); 6.15 + void super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2); 6.16 6.17 // Generate a subtype check: branch to ok_is_subtype if sub_klass is 6.18 // a subtype of super_klass. Blows registers tmp1, tmp2 and tmp3.
7.1 --- a/src/cpu/sparc/vm/stubGenerator_sparc.cpp Tue Mar 09 11:02:39 2010 -0800 7.2 +++ b/src/cpu/sparc/vm/stubGenerator_sparc.cpp Tue Mar 09 23:57:36 2010 -0800 7.3 @@ -379,7 +379,7 @@ 7.4 __ save_frame(0); // compensates for compiler weakness 7.5 __ add(O7->after_save(), frame::pc_return_offset, Lscratch); // save the issuing PC 7.6 BLOCK_COMMENT("call exception_handler_for_return_address"); 7.7 - __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), Lscratch); 7.8 + __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), G2_thread, Lscratch); 7.9 __ mov(O0, handler_reg); 7.10 __ restore(); // compensates for compiler weakness 7.11
8.1 --- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp Tue Mar 09 11:02:39 2010 -0800 8.2 +++ b/src/cpu/sparc/vm/templateInterpreter_sparc.cpp Tue Mar 09 23:57:36 2010 -0800 8.3 @@ -1,5 +1,5 @@ 8.4 /* 8.5 - * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. 8.6 + * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved. 8.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 * 8.9 * This code is free software; you can redistribute it and/or modify it 8.10 @@ -1822,7 +1822,7 @@ 8.11 __ add(issuing_pc_addr, Oissuing_pc->after_save()); // likewise set I1 to a value local to the caller 8.12 __ super_call_VM_leaf(L7_thread_cache, 8.13 CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), 8.14 - Oissuing_pc->after_save()); 8.15 + G2_thread, Oissuing_pc->after_save()); 8.16 8.17 // The caller's SP was adjusted upon method entry to accomodate 8.18 // the callee's non-argument locals. Undo that adjustment.
9.1 --- a/src/cpu/x86/vm/c1_CodeStubs_x86.cpp Tue Mar 09 11:02:39 2010 -0800 9.2 +++ b/src/cpu/x86/vm/c1_CodeStubs_x86.cpp Tue Mar 09 23:57:36 2010 -0800 9.3 @@ -1,5 +1,5 @@ 9.4 /* 9.5 - * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. 9.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 9.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.8 * 9.9 * This code is free software; you can redistribute it and/or modify it 9.10 @@ -373,6 +373,14 @@ 9.11 } 9.12 9.13 9.14 +void DeoptimizeStub::emit_code(LIR_Assembler* ce) { 9.15 + __ bind(_entry); 9.16 + __ call(RuntimeAddress(SharedRuntime::deopt_blob()->unpack_with_reexecution())); 9.17 + ce->add_call_info_here(_info); 9.18 + debug_only(__ should_not_reach_here()); 9.19 +} 9.20 + 9.21 + 9.22 void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { 9.23 ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); 9.24 __ bind(_entry);
10.1 --- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Tue Mar 09 11:02:39 2010 -0800 10.2 +++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Tue Mar 09 23:57:36 2010 -0800 10.3 @@ -436,40 +436,18 @@ 10.4 10.5 int offset = code_offset(); 10.6 10.7 - // if the method does not have an exception handler, then there is 10.8 - // no reason to search for one 10.9 - if (compilation()->has_exception_handlers() || compilation()->env()->jvmti_can_post_on_exceptions()) { 10.10 - // the exception oop and pc are in rax, and rdx 10.11 - // no other registers need to be preserved, so invalidate them 10.12 - __ invalidate_registers(false, true, true, false, true, true); 10.13 - 10.14 - // check that there is really an exception 10.15 - __ verify_not_null_oop(rax); 10.16 - 10.17 - // search an exception handler (rax: exception oop, rdx: throwing pc) 10.18 - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_nofpu_id))); 10.19 - 10.20 - // if the call returns here, then the exception handler for particular 10.21 - // exception doesn't exist -> unwind activation and forward exception to caller 10.22 - } 10.23 - 10.24 - // the exception oop is in rax, 10.25 + // the exception oop and pc are in rax, and rdx 10.26 // no other registers need to be preserved, so invalidate them 10.27 - __ invalidate_registers(false, true, true, true, true, true); 10.28 + __ invalidate_registers(false, true, true, false, true, true); 10.29 10.30 // check that there is really an exception 10.31 __ verify_not_null_oop(rax); 10.32 10.33 - // unlock the receiver/klass if necessary 10.34 - // rax,: exception 10.35 - ciMethod* method = compilation()->method(); 10.36 - if (method->is_synchronized() && GenerateSynchronizationCode) { 10.37 - monitorexit(FrameMap::rbx_oop_opr, FrameMap::rcx_opr, SYNC_header, 0, rax); 10.38 - } 10.39 - 10.40 - // unwind activation and forward exception to caller 10.41 - // rax,: exception 10.42 - __ jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id))); 10.43 + // search an exception handler (rax: exception oop, rdx: throwing pc) 10.44 + __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_nofpu_id))); 10.45 + 10.46 + __ stop("should not reach here"); 10.47 + 10.48 assert(code_offset() - offset <= exception_handler_size, "overflow"); 10.49 __ end_a_stub(); 10.50 10.51 @@ -495,8 +473,10 @@ 10.52 10.53 int offset = code_offset(); 10.54 InternalAddress here(__ pc()); 10.55 + 10.56 __ pushptr(here.addr()); 10.57 __ jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack())); 10.58 + 10.59 assert(code_offset() - offset <= deopt_handler_size, "overflow"); 10.60 __ end_a_stub(); 10.61 10.62 @@ -593,7 +573,7 @@ 10.63 } 10.64 10.65 // Pop the stack before the safepoint code 10.66 - __ leave(); 10.67 + __ remove_frame(initial_frame_size_in_bytes()); 10.68 10.69 bool result_is_oop = result->is_valid() ? result->is_oop() : false; 10.70 10.71 @@ -2738,6 +2718,7 @@ 10.72 switch (code) { 10.73 case lir_static_call: 10.74 case lir_optvirtual_call: 10.75 + case lir_dynamic_call: 10.76 offset += NativeCall::displacement_offset; 10.77 break; 10.78 case lir_icvirtual_call: 10.79 @@ -2753,30 +2734,41 @@ 10.80 } 10.81 10.82 10.83 -void LIR_Assembler::call(address entry, relocInfo::relocType rtype, CodeEmitInfo* info) { 10.84 +void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) { 10.85 assert(!os::is_MP() || (__ offset() + NativeCall::displacement_offset) % BytesPerWord == 0, 10.86 "must be aligned"); 10.87 - __ call(AddressLiteral(entry, rtype)); 10.88 - add_call_info(code_offset(), info); 10.89 + __ call(AddressLiteral(op->addr(), rtype)); 10.90 + add_call_info(code_offset(), op->info(), op->is_method_handle_invoke()); 10.91 } 10.92 10.93 10.94 -void LIR_Assembler::ic_call(address entry, CodeEmitInfo* info) { 10.95 +void LIR_Assembler::ic_call(LIR_OpJavaCall* op) { 10.96 RelocationHolder rh = virtual_call_Relocation::spec(pc()); 10.97 __ movoop(IC_Klass, (jobject)Universe::non_oop_word()); 10.98 assert(!os::is_MP() || 10.99 (__ offset() + NativeCall::displacement_offset) % BytesPerWord == 0, 10.100 "must be aligned"); 10.101 - __ call(AddressLiteral(entry, rh)); 10.102 - add_call_info(code_offset(), info); 10.103 + __ call(AddressLiteral(op->addr(), rh)); 10.104 + add_call_info(code_offset(), op->info(), op->is_method_handle_invoke()); 10.105 } 10.106 10.107 10.108 /* Currently, vtable-dispatch is only enabled for sparc platforms */ 10.109 -void LIR_Assembler::vtable_call(int vtable_offset, CodeEmitInfo* info) { 10.110 +void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) { 10.111 ShouldNotReachHere(); 10.112 } 10.113 10.114 + 10.115 +void LIR_Assembler::preserve_SP() { 10.116 + __ movptr(rbp, rsp); 10.117 +} 10.118 + 10.119 + 10.120 +void LIR_Assembler::restore_SP() { 10.121 + __ movptr(rsp, rbp); 10.122 +} 10.123 + 10.124 + 10.125 void LIR_Assembler::emit_static_call_stub() { 10.126 address call_pc = __ pc(); 10.127 address stub = __ start_a_stub(call_stub_size); 10.128 @@ -2829,10 +2821,12 @@ 10.129 } else { 10.130 unwind_id = Runtime1::handle_exception_nofpu_id; 10.131 } 10.132 + __ call(RuntimeAddress(Runtime1::entry_for(unwind_id))); 10.133 } else { 10.134 - unwind_id = Runtime1::unwind_exception_id; 10.135 + // remove the activation 10.136 + __ remove_frame(initial_frame_size_in_bytes()); 10.137 + __ jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id))); 10.138 } 10.139 - __ call(RuntimeAddress(Runtime1::entry_for(unwind_id))); 10.140 10.141 // enough room for two byte trap 10.142 __ nop();
11.1 --- a/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Tue Mar 09 11:02:39 2010 -0800 11.2 +++ b/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Tue Mar 09 23:57:36 2010 -0800 11.3 @@ -1,5 +1,5 @@ 11.4 /* 11.5 - * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. 11.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 11.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.8 * 11.9 * This code is free software; you can redistribute it and/or modify it 11.10 @@ -317,14 +317,6 @@ 11.11 } 11.12 11.13 11.14 -void C1_MacroAssembler::method_exit(bool restore_frame) { 11.15 - if (restore_frame) { 11.16 - leave(); 11.17 - } 11.18 - ret(0); 11.19 -} 11.20 - 11.21 - 11.22 void C1_MacroAssembler::build_frame(int frame_size_in_bytes) { 11.23 // Make sure there is enough stack space for this method's activation. 11.24 // Note that we do this before doing an enter(). This matches the 11.25 @@ -333,7 +325,7 @@ 11.26 // between the two compilers. 11.27 generate_stack_overflow_check(frame_size_in_bytes); 11.28 11.29 - enter(); 11.30 + push(rbp); 11.31 #ifdef TIERED 11.32 // c2 leaves fpu stack dirty. Clean it on entry 11.33 if (UseSSE < 2 ) { 11.34 @@ -344,6 +336,12 @@ 11.35 } 11.36 11.37 11.38 +void C1_MacroAssembler::remove_frame(int frame_size_in_bytes) { 11.39 + increment(rsp, frame_size_in_bytes); // Does not emit code for frame_size == 0 11.40 + pop(rbp); 11.41 +} 11.42 + 11.43 + 11.44 void C1_MacroAssembler::unverified_entry(Register receiver, Register ic_klass) { 11.45 if (C1Breakpoint) int3(); 11.46 inline_cache_check(receiver, ic_klass);
12.1 --- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp Tue Mar 09 11:02:39 2010 -0800 12.2 +++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp Tue Mar 09 23:57:36 2010 -0800 12.3 @@ -1,5 +1,5 @@ 12.4 /* 12.5 - * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. 12.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 12.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.8 * 12.9 * This code is free software; you can redistribute it and/or modify it 12.10 @@ -688,18 +688,21 @@ 12.11 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc)); 12.12 oop_maps->add_gc_map(call_offset, oop_map); 12.13 12.14 - // rax,: handler address or NULL if no handler exists 12.15 + // rax,: handler address 12.16 // will be the deopt blob if nmethod was deoptimized while we looked up 12.17 // handler regardless of whether handler existed in the nmethod. 12.18 12.19 // only rax, is valid at this time, all other registers have been destroyed by the runtime call 12.20 __ invalidate_registers(false, true, true, true, true, true); 12.21 12.22 +#ifdef ASSERT 12.23 // Do we have an exception handler in the nmethod? 12.24 - Label no_handler; 12.25 Label done; 12.26 __ testptr(rax, rax); 12.27 - __ jcc(Assembler::zero, no_handler); 12.28 + __ jcc(Assembler::notZero, done); 12.29 + __ stop("no handler found"); 12.30 + __ bind(done); 12.31 +#endif 12.32 12.33 // exception handler found 12.34 // patch the return address -> the stub will directly return to the exception handler 12.35 @@ -712,36 +715,14 @@ 12.36 __ leave(); 12.37 __ ret(0); 12.38 12.39 - __ bind(no_handler); 12.40 - // no exception handler found in this method, so the exception is 12.41 - // forwarded to the caller (using the unwind code of the nmethod) 12.42 - // there is no need to restore the registers 12.43 - 12.44 - // restore the real return address that was saved before the RT-call 12.45 - __ movptr(real_return_addr, Address(rsp, temp_1_off * VMRegImpl::stack_slot_size)); 12.46 - __ movptr(Address(rbp, 1*BytesPerWord), real_return_addr); 12.47 - 12.48 - // load address of JavaThread object for thread-local data 12.49 - NOT_LP64(__ get_thread(thread);) 12.50 - // restore exception oop into rax, (convention for unwind code) 12.51 - __ movptr(exception_oop, Address(thread, JavaThread::exception_oop_offset())); 12.52 - 12.53 - // clear exception fields in JavaThread because they are no longer needed 12.54 - // (fields must be cleared because they are processed by GC otherwise) 12.55 - __ movptr(Address(thread, JavaThread::exception_oop_offset()), NULL_WORD); 12.56 - __ movptr(Address(thread, JavaThread::exception_pc_offset()), NULL_WORD); 12.57 - 12.58 - // pop the stub frame off 12.59 - __ leave(); 12.60 - 12.61 - generate_unwind_exception(sasm); 12.62 - __ stop("should not reach here"); 12.63 } 12.64 12.65 12.66 void Runtime1::generate_unwind_exception(StubAssembler *sasm) { 12.67 // incoming parameters 12.68 const Register exception_oop = rax; 12.69 + // callee-saved copy of exception_oop during runtime call 12.70 + const Register exception_oop_callee_saved = NOT_LP64(rsi) LP64_ONLY(r14); 12.71 // other registers used in this stub 12.72 const Register exception_pc = rdx; 12.73 const Register handler_addr = rbx; 12.74 @@ -769,38 +750,39 @@ 12.75 // clear the FPU stack in case any FPU results are left behind 12.76 __ empty_FPU_stack(); 12.77 12.78 - // leave activation of nmethod 12.79 - __ leave(); 12.80 - // store return address (is on top of stack after leave) 12.81 + // save exception_oop in callee-saved register to preserve it during runtime calls 12.82 + __ verify_not_null_oop(exception_oop); 12.83 + __ movptr(exception_oop_callee_saved, exception_oop); 12.84 + 12.85 + NOT_LP64(__ get_thread(thread);) 12.86 + // Get return address (is on top of stack after leave). 12.87 __ movptr(exception_pc, Address(rsp, 0)); 12.88 12.89 - __ verify_oop(exception_oop); 12.90 + // search the exception handler address of the caller (using the return address) 12.91 + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), thread, exception_pc); 12.92 + // rax: exception handler address of the caller 12.93 12.94 - // save exception oop from rax, to stack before call 12.95 - __ push(exception_oop); 12.96 - 12.97 - // search the exception handler address of the caller (using the return address) 12.98 - __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), exception_pc); 12.99 - // rax,: exception handler address of the caller 12.100 - 12.101 - // only rax, is valid at this time, all other registers have been destroyed by the call 12.102 - __ invalidate_registers(false, true, true, true, true, true); 12.103 + // Only RAX and RSI are valid at this time, all other registers have been destroyed by the call. 12.104 + __ invalidate_registers(false, true, true, true, false, true); 12.105 12.106 // move result of call into correct register 12.107 __ movptr(handler_addr, rax); 12.108 12.109 - // restore exception oop in rax, (required convention of exception handler) 12.110 - __ pop(exception_oop); 12.111 + // Restore exception oop to RAX (required convention of exception handler). 12.112 + __ movptr(exception_oop, exception_oop_callee_saved); 12.113 12.114 - __ verify_oop(exception_oop); 12.115 + // verify that there is really a valid exception in rax 12.116 + __ verify_not_null_oop(exception_oop); 12.117 12.118 // get throwing pc (= return address). 12.119 // rdx has been destroyed by the call, so it must be set again 12.120 // the pop is also necessary to simulate the effect of a ret(0) 12.121 __ pop(exception_pc); 12.122 12.123 - // verify that that there is really a valid exception in rax, 12.124 - __ verify_not_null_oop(exception_oop); 12.125 + // Restore SP from BP if the exception PC is a MethodHandle call site. 12.126 + NOT_LP64(__ get_thread(thread);) 12.127 + __ cmpl(Address(thread, JavaThread::is_method_handle_exception_offset()), 0); 12.128 + __ cmovptr(Assembler::notEqual, rsp, rbp); 12.129 12.130 // continue at exception handler (return address removed) 12.131 // note: do *not* remove arguments when unwinding the 12.132 @@ -808,9 +790,9 @@ 12.133 // all arguments on the stack when entering the 12.134 // runtime to determine the exception handler 12.135 // (GC happens at call site with arguments!) 12.136 - // rax,: exception oop 12.137 + // rax: exception oop 12.138 // rdx: throwing pc 12.139 - // rbx,: exception handler 12.140 + // rbx: exception handler 12.141 __ jmp(handler_addr); 12.142 } 12.143
13.1 --- a/src/cpu/x86/vm/stubGenerator_x86_32.cpp Tue Mar 09 11:02:39 2010 -0800 13.2 +++ b/src/cpu/x86/vm/stubGenerator_x86_32.cpp Tue Mar 09 23:57:36 2010 -0800 13.3 @@ -369,7 +369,7 @@ 13.4 // The pending exception in Thread is converted into a Java-level exception. 13.5 // 13.6 // Contract with Java-level exception handlers: 13.7 - // rax,: exception 13.8 + // rax: exception 13.9 // rdx: throwing pc 13.10 // 13.11 // NOTE: At entry of this stub, exception-pc must be on stack !! 13.12 @@ -377,6 +377,12 @@ 13.13 address generate_forward_exception() { 13.14 StubCodeMark mark(this, "StubRoutines", "forward exception"); 13.15 address start = __ pc(); 13.16 + const Register thread = rcx; 13.17 + 13.18 + // other registers used in this stub 13.19 + const Register exception_oop = rax; 13.20 + const Register handler_addr = rbx; 13.21 + const Register exception_pc = rdx; 13.22 13.23 // Upon entry, the sp points to the return address returning into Java 13.24 // (interpreted or compiled) code; i.e., the return address becomes the 13.25 @@ -389,8 +395,8 @@ 13.26 #ifdef ASSERT 13.27 // make sure this code is only executed if there is a pending exception 13.28 { Label L; 13.29 - __ get_thread(rcx); 13.30 - __ cmpptr(Address(rcx, Thread::pending_exception_offset()), (int32_t)NULL_WORD); 13.31 + __ get_thread(thread); 13.32 + __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); 13.33 __ jcc(Assembler::notEqual, L); 13.34 __ stop("StubRoutines::forward exception: no pending exception (1)"); 13.35 __ bind(L); 13.36 @@ -398,33 +404,40 @@ 13.37 #endif 13.38 13.39 // compute exception handler into rbx, 13.40 - __ movptr(rax, Address(rsp, 0)); 13.41 + __ get_thread(thread); 13.42 + __ movptr(exception_pc, Address(rsp, 0)); 13.43 BLOCK_COMMENT("call exception_handler_for_return_address"); 13.44 - __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), rax); 13.45 - __ mov(rbx, rax); 13.46 + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), thread, exception_pc); 13.47 + __ mov(handler_addr, rax); 13.48 13.49 - // setup rax, & rdx, remove return address & clear pending exception 13.50 - __ get_thread(rcx); 13.51 - __ pop(rdx); 13.52 - __ movptr(rax, Address(rcx, Thread::pending_exception_offset())); 13.53 - __ movptr(Address(rcx, Thread::pending_exception_offset()), NULL_WORD); 13.54 + // setup rax & rdx, remove return address & clear pending exception 13.55 + __ get_thread(thread); 13.56 + __ pop(exception_pc); 13.57 + __ movptr(exception_oop, Address(thread, Thread::pending_exception_offset())); 13.58 + __ movptr(Address(thread, Thread::pending_exception_offset()), NULL_WORD); 13.59 13.60 #ifdef ASSERT 13.61 // make sure exception is set 13.62 { Label L; 13.63 - __ testptr(rax, rax); 13.64 + __ testptr(exception_oop, exception_oop); 13.65 __ jcc(Assembler::notEqual, L); 13.66 __ stop("StubRoutines::forward exception: no pending exception (2)"); 13.67 __ bind(L); 13.68 } 13.69 #endif 13.70 13.71 + // Verify that there is really a valid exception in RAX. 13.72 + __ verify_oop(exception_oop); 13.73 + 13.74 + // Restore SP from BP if the exception PC is a MethodHandle call site. 13.75 + __ cmpl(Address(thread, JavaThread::is_method_handle_exception_offset()), 0); 13.76 + __ cmovptr(Assembler::notEqual, rsp, rbp); 13.77 + 13.78 // continue at exception handler (return address removed) 13.79 - // rax,: exception 13.80 - // rbx,: exception handler 13.81 + // rax: exception 13.82 + // rbx: exception handler 13.83 // rdx: throwing pc 13.84 - __ verify_oop(rax); 13.85 - __ jmp(rbx); 13.86 + __ jmp(handler_addr); 13.87 13.88 return start; 13.89 }
14.1 --- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp Tue Mar 09 11:02:39 2010 -0800 14.2 +++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp Tue Mar 09 23:57:36 2010 -0800 14.3 @@ -466,7 +466,7 @@ 14.4 BLOCK_COMMENT("call exception_handler_for_return_address"); 14.5 __ call_VM_leaf(CAST_FROM_FN_PTR(address, 14.6 SharedRuntime::exception_handler_for_return_address), 14.7 - c_rarg0); 14.8 + r15_thread, c_rarg0); 14.9 __ mov(rbx, rax); 14.10 14.11 // setup rax & rdx, remove return address & clear pending exception
15.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_32.cpp Tue Mar 09 11:02:39 2010 -0800 15.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_32.cpp Tue Mar 09 23:57:36 2010 -0800 15.3 @@ -1550,6 +1550,7 @@ 15.4 void TemplateInterpreterGenerator::generate_throw_exception() { 15.5 // Entry point in previous activation (i.e., if the caller was interpreted) 15.6 Interpreter::_rethrow_exception_entry = __ pc(); 15.7 + const Register thread = rcx; 15.8 15.9 // Restore sp to interpreter_frame_last_sp even though we are going 15.10 // to empty the expression stack for the exception processing. 15.11 @@ -1598,10 +1599,10 @@ 15.12 // Set the popframe_processing bit in pending_popframe_condition indicating that we are 15.13 // currently handling popframe, so that call_VMs that may happen later do not trigger new 15.14 // popframe handling cycles. 15.15 - __ get_thread(rcx); 15.16 - __ movl(rdx, Address(rcx, JavaThread::popframe_condition_offset())); 15.17 + __ get_thread(thread); 15.18 + __ movl(rdx, Address(thread, JavaThread::popframe_condition_offset())); 15.19 __ orl(rdx, JavaThread::popframe_processing_bit); 15.20 - __ movl(Address(rcx, JavaThread::popframe_condition_offset()), rdx); 15.21 + __ movl(Address(thread, JavaThread::popframe_condition_offset()), rdx); 15.22 15.23 { 15.24 // Check to see whether we are returning to a deoptimized frame. 15.25 @@ -1629,8 +1630,8 @@ 15.26 __ subptr(rdi, rax); 15.27 __ addptr(rdi, wordSize); 15.28 // Save these arguments 15.29 - __ get_thread(rcx); 15.30 - __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args), rcx, rax, rdi); 15.31 + __ get_thread(thread); 15.32 + __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args), thread, rax, rdi); 15.33 15.34 __ remove_activation(vtos, rdx, 15.35 /* throw_monitor_exception */ false, 15.36 @@ -1638,8 +1639,8 @@ 15.37 /* notify_jvmdi */ false); 15.38 15.39 // Inform deoptimization that it is responsible for restoring these arguments 15.40 - __ get_thread(rcx); 15.41 - __ movl(Address(rcx, JavaThread::popframe_condition_offset()), JavaThread::popframe_force_deopt_reexecution_bit); 15.42 + __ get_thread(thread); 15.43 + __ movl(Address(thread, JavaThread::popframe_condition_offset()), JavaThread::popframe_force_deopt_reexecution_bit); 15.44 15.45 // Continue in deoptimization handler 15.46 __ jmp(rdx); 15.47 @@ -1665,12 +1666,12 @@ 15.48 // expression stack if necessary. 15.49 __ mov(rax, rsp); 15.50 __ movptr(rbx, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); 15.51 - __ get_thread(rcx); 15.52 + __ get_thread(thread); 15.53 // PC must point into interpreter here 15.54 - __ set_last_Java_frame(rcx, noreg, rbp, __ pc()); 15.55 - __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), rcx, rax, rbx); 15.56 - __ get_thread(rcx); 15.57 - __ reset_last_Java_frame(rcx, true, true); 15.58 + __ set_last_Java_frame(thread, noreg, rbp, __ pc()); 15.59 + __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), thread, rax, rbx); 15.60 + __ get_thread(thread); 15.61 + __ reset_last_Java_frame(thread, true, true); 15.62 // Restore the last_sp and null it out 15.63 __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); 15.64 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD); 15.65 @@ -1684,8 +1685,8 @@ 15.66 } 15.67 15.68 // Clear the popframe condition flag 15.69 - __ get_thread(rcx); 15.70 - __ movl(Address(rcx, JavaThread::popframe_condition_offset()), JavaThread::popframe_inactive); 15.71 + __ get_thread(thread); 15.72 + __ movl(Address(thread, JavaThread::popframe_condition_offset()), JavaThread::popframe_inactive); 15.73 15.74 __ dispatch_next(vtos); 15.75 // end of PopFrame support 15.76 @@ -1694,27 +1695,27 @@ 15.77 15.78 // preserve exception over this code sequence 15.79 __ pop_ptr(rax); 15.80 - __ get_thread(rcx); 15.81 - __ movptr(Address(rcx, JavaThread::vm_result_offset()), rax); 15.82 + __ get_thread(thread); 15.83 + __ movptr(Address(thread, JavaThread::vm_result_offset()), rax); 15.84 // remove the activation (without doing throws on illegalMonitorExceptions) 15.85 __ remove_activation(vtos, rdx, false, true, false); 15.86 // restore exception 15.87 - __ get_thread(rcx); 15.88 - __ movptr(rax, Address(rcx, JavaThread::vm_result_offset())); 15.89 - __ movptr(Address(rcx, JavaThread::vm_result_offset()), NULL_WORD); 15.90 + __ get_thread(thread); 15.91 + __ movptr(rax, Address(thread, JavaThread::vm_result_offset())); 15.92 + __ movptr(Address(thread, JavaThread::vm_result_offset()), NULL_WORD); 15.93 __ verify_oop(rax); 15.94 15.95 // Inbetween activations - previous activation type unknown yet 15.96 // compute continuation point - the continuation point expects 15.97 // the following registers set up: 15.98 // 15.99 - // rax,: exception 15.100 + // rax: exception 15.101 // rdx: return address/pc that threw exception 15.102 // rsp: expression stack of caller 15.103 - // rbp,: rbp, of caller 15.104 + // rbp: rbp, of caller 15.105 __ push(rax); // save exception 15.106 __ push(rdx); // save return address 15.107 - __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), rdx); 15.108 + __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), thread, rdx); 15.109 __ mov(rbx, rax); // save exception handler 15.110 __ pop(rdx); // restore return address 15.111 __ pop(rax); // restore exception 15.112 @@ -1728,6 +1729,7 @@ 15.113 // 15.114 address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) { 15.115 address entry = __ pc(); 15.116 + const Register thread = rcx; 15.117 15.118 __ restore_bcp(); 15.119 __ restore_locals(); 15.120 @@ -1735,8 +1737,8 @@ 15.121 __ empty_FPU_stack(); 15.122 __ load_earlyret_value(state); 15.123 15.124 - __ get_thread(rcx); 15.125 - __ movptr(rcx, Address(rcx, JavaThread::jvmti_thread_state_offset())); 15.126 + __ get_thread(thread); 15.127 + __ movptr(rcx, Address(thread, JavaThread::jvmti_thread_state_offset())); 15.128 const Address cond_addr(rcx, JvmtiThreadState::earlyret_state_offset()); 15.129 15.130 // Clear the earlyret state
16.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Tue Mar 09 11:02:39 2010 -0800 16.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Tue Mar 09 23:57:36 2010 -0800 16.3 @@ -1741,7 +1741,7 @@ 16.4 __ push(rdx); // save return address 16.5 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, 16.6 SharedRuntime::exception_handler_for_return_address), 16.7 - rdx); 16.8 + r15_thread, rdx); 16.9 __ mov(rbx, rax); // save exception handler 16.10 __ pop(rdx); // restore return address 16.11 __ pop(rax); // restore exception
17.1 --- a/src/share/vm/c1/c1_Canonicalizer.cpp Tue Mar 09 11:02:39 2010 -0800 17.2 +++ b/src/share/vm/c1/c1_Canonicalizer.cpp Tue Mar 09 23:57:36 2010 -0800 17.3 @@ -1,5 +1,5 @@ 17.4 /* 17.5 - * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. 17.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 17.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.8 * 17.9 * This code is free software; you can redistribute it and/or modify it 17.10 @@ -222,11 +222,15 @@ 17.11 } 17.12 } else { 17.13 LoadField* lf = x->array()->as_LoadField(); 17.14 - if (lf != NULL && lf->field()->is_constant()) { 17.15 - ciObject* c = lf->field()->constant_value().as_object(); 17.16 - if (c->is_array()) { 17.17 - ciArray* array = (ciArray*) c; 17.18 - set_constant(array->length()); 17.19 + if (lf != NULL) { 17.20 + ciField* field = lf->field(); 17.21 + if (field->is_constant() && field->is_static()) { 17.22 + // final static field 17.23 + ciObject* c = field->constant_value().as_object(); 17.24 + if (c->is_array()) { 17.25 + ciArray* array = (ciArray*) c; 17.26 + set_constant(array->length()); 17.27 + } 17.28 } 17.29 } 17.30 }
18.1 --- a/src/share/vm/c1/c1_CodeStubs.hpp Tue Mar 09 11:02:39 2010 -0800 18.2 +++ b/src/share/vm/c1/c1_CodeStubs.hpp Tue Mar 09 23:57:36 2010 -0800 18.3 @@ -1,5 +1,5 @@ 18.4 /* 18.5 - * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. 18.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 18.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.8 * 18.9 * This code is free software; you can redistribute it and/or modify it 18.10 @@ -415,6 +415,28 @@ 18.11 }; 18.12 18.13 18.14 +//------------------------------------------------------------------------------ 18.15 +// DeoptimizeStub 18.16 +// 18.17 +class DeoptimizeStub : public CodeStub { 18.18 +private: 18.19 + CodeEmitInfo* _info; 18.20 + 18.21 +public: 18.22 + DeoptimizeStub(CodeEmitInfo* info) : _info(new CodeEmitInfo(info)) {} 18.23 + 18.24 + virtual void emit_code(LIR_Assembler* e); 18.25 + virtual CodeEmitInfo* info() const { return _info; } 18.26 + virtual bool is_exception_throw_stub() const { return true; } 18.27 + virtual void visit(LIR_OpVisitState* visitor) { 18.28 + visitor->do_slow_case(_info); 18.29 + } 18.30 +#ifndef PRODUCT 18.31 + virtual void print_name(outputStream* out) const { out->print("DeoptimizeStub"); } 18.32 +#endif // PRODUCT 18.33 +}; 18.34 + 18.35 + 18.36 class SimpleExceptionStub: public CodeStub { 18.37 private: 18.38 LIR_Opr _obj;
19.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Tue Mar 09 11:02:39 2010 -0800 19.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Tue Mar 09 23:57:36 2010 -0800 19.3 @@ -1,5 +1,5 @@ 19.4 /* 19.5 - * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. 19.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 19.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.8 * 19.9 * This code is free software; you can redistribute it and/or modify it 19.10 @@ -1524,18 +1524,14 @@ 19.11 code = Bytecodes::_invokespecial; 19.12 } 19.13 19.14 - if (code == Bytecodes::_invokedynamic) { 19.15 - BAILOUT("invokedynamic NYI"); // FIXME 19.16 - return; 19.17 - } 19.18 - 19.19 // NEEDS_CLEANUP 19.20 // I've added the target-is_loaded() test below but I don't really understand 19.21 // how klass->is_loaded() can be true and yet target->is_loaded() is false. 19.22 // this happened while running the JCK invokevirtual tests under doit. TKR 19.23 ciMethod* cha_monomorphic_target = NULL; 19.24 ciMethod* exact_target = NULL; 19.25 - if (UseCHA && DeoptC1 && klass->is_loaded() && target->is_loaded()) { 19.26 + if (UseCHA && DeoptC1 && klass->is_loaded() && target->is_loaded() && 19.27 + !target->is_method_handle_invoke()) { 19.28 Value receiver = NULL; 19.29 ciInstanceKlass* receiver_klass = NULL; 19.30 bool type_is_exact = false; 19.31 @@ -1681,11 +1677,20 @@ 19.32 CHECK_BAILOUT(); 19.33 19.34 // inlining not successful => standard invoke 19.35 - bool is_static = code == Bytecodes::_invokestatic; 19.36 + bool is_loaded = target->is_loaded(); 19.37 + bool has_receiver = 19.38 + code == Bytecodes::_invokespecial || 19.39 + code == Bytecodes::_invokevirtual || 19.40 + code == Bytecodes::_invokeinterface; 19.41 + bool is_invokedynamic = code == Bytecodes::_invokedynamic; 19.42 ValueType* result_type = as_ValueType(target->return_type()); 19.43 + 19.44 + // We require the debug info to be the "state before" because 19.45 + // invokedynamics may deoptimize. 19.46 + ValueStack* state_before = is_invokedynamic ? state()->copy() : NULL; 19.47 + 19.48 Values* args = state()->pop_arguments(target->arg_size_no_receiver()); 19.49 - Value recv = is_static ? NULL : apop(); 19.50 - bool is_loaded = target->is_loaded(); 19.51 + Value recv = has_receiver ? apop() : NULL; 19.52 int vtable_index = methodOopDesc::invalid_vtable_index; 19.53 19.54 #ifdef SPARC 19.55 @@ -1723,7 +1728,7 @@ 19.56 profile_call(recv, target_klass); 19.57 } 19.58 19.59 - Invoke* result = new Invoke(code, result_type, recv, args, vtable_index, target); 19.60 + Invoke* result = new Invoke(code, result_type, recv, args, vtable_index, target, state_before); 19.61 // push result 19.62 append_split(result); 19.63 19.64 @@ -2862,20 +2867,18 @@ 19.65 _initial_state = state_at_entry(); 19.66 start_block->merge(_initial_state); 19.67 19.68 - BlockBegin* sync_handler = NULL; 19.69 - if (method()->is_synchronized() || _compilation->env()->dtrace_method_probes()) { 19.70 - // setup an exception handler to do the unlocking and/or notification 19.71 - sync_handler = new BlockBegin(-1); 19.72 - sync_handler->set(BlockBegin::exception_entry_flag); 19.73 - sync_handler->set(BlockBegin::is_on_work_list_flag); 19.74 - sync_handler->set(BlockBegin::default_exception_handler_flag); 19.75 - 19.76 - ciExceptionHandler* desc = new ciExceptionHandler(method()->holder(), 0, method()->code_size(), -1, 0); 19.77 - XHandler* h = new XHandler(desc); 19.78 - h->set_entry_block(sync_handler); 19.79 - scope_data()->xhandlers()->append(h); 19.80 - scope_data()->set_has_handler(); 19.81 - } 19.82 + // setup an exception handler to do the unlocking and/or 19.83 + // notification and unwind the frame. 19.84 + BlockBegin* sync_handler = new BlockBegin(-1); 19.85 + sync_handler->set(BlockBegin::exception_entry_flag); 19.86 + sync_handler->set(BlockBegin::is_on_work_list_flag); 19.87 + sync_handler->set(BlockBegin::default_exception_handler_flag); 19.88 + 19.89 + ciExceptionHandler* desc = new ciExceptionHandler(method()->holder(), 0, method()->code_size(), -1, 0); 19.90 + XHandler* h = new XHandler(desc); 19.91 + h->set_entry_block(sync_handler); 19.92 + scope_data()->xhandlers()->append(h); 19.93 + scope_data()->set_has_handler(); 19.94 19.95 // complete graph 19.96 _vmap = new ValueMap();
20.1 --- a/src/share/vm/c1/c1_IR.cpp Tue Mar 09 11:02:39 2010 -0800 20.2 +++ b/src/share/vm/c1/c1_IR.cpp Tue Mar 09 23:57:36 2010 -0800 20.3 @@ -1,5 +1,5 @@ 20.4 /* 20.5 - * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. 20.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 20.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.8 * 20.9 * This code is free software; you can redistribute it and/or modify it 20.10 @@ -259,10 +259,10 @@ 20.11 } 20.12 20.13 20.14 -void CodeEmitInfo::record_debug_info(DebugInformationRecorder* recorder, int pc_offset) { 20.15 +void CodeEmitInfo::record_debug_info(DebugInformationRecorder* recorder, int pc_offset, bool is_method_handle_invoke) { 20.16 // record the safepoint before recording the debug info for enclosing scopes 20.17 recorder->add_safepoint(pc_offset, _oop_map->deep_copy()); 20.18 - _scope_debug_info->record_debug_info(recorder, pc_offset, true/*topmost*/); 20.19 + _scope_debug_info->record_debug_info(recorder, pc_offset, true/*topmost*/, is_method_handle_invoke); 20.20 recorder->end_safepoint(pc_offset); 20.21 } 20.22
21.1 --- a/src/share/vm/c1/c1_IR.hpp Tue Mar 09 11:02:39 2010 -0800 21.2 +++ b/src/share/vm/c1/c1_IR.hpp Tue Mar 09 23:57:36 2010 -0800 21.3 @@ -1,5 +1,5 @@ 21.4 /* 21.5 - * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. 21.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 21.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.8 * 21.9 * This code is free software; you can redistribute it and/or modify it 21.10 @@ -242,7 +242,7 @@ 21.11 //Whether we should reexecute this bytecode for deopt 21.12 bool should_reexecute(); 21.13 21.14 - void record_debug_info(DebugInformationRecorder* recorder, int pc_offset, bool topmost) { 21.15 + void record_debug_info(DebugInformationRecorder* recorder, int pc_offset, bool topmost, bool is_method_handle_invoke = false) { 21.16 if (caller() != NULL) { 21.17 // Order is significant: Must record caller first. 21.18 caller()->record_debug_info(recorder, pc_offset, false/*topmost*/); 21.19 @@ -252,7 +252,6 @@ 21.20 DebugToken* monvals = recorder->create_monitor_values(monitors()); 21.21 // reexecute allowed only for the topmost frame 21.22 bool reexecute = topmost ? should_reexecute() : false; 21.23 - bool is_method_handle_invoke = false; 21.24 bool return_oop = false; // This flag will be ignored since it used only for C2 with escape analysis. 21.25 recorder->describe_scope(pc_offset, scope()->method(), bci(), reexecute, is_method_handle_invoke, return_oop, locvals, expvals, monvals); 21.26 } 21.27 @@ -303,7 +302,7 @@ 21.28 int bci() const { return _bci; } 21.29 21.30 void add_register_oop(LIR_Opr opr); 21.31 - void record_debug_info(DebugInformationRecorder* recorder, int pc_offset); 21.32 + void record_debug_info(DebugInformationRecorder* recorder, int pc_offset, bool is_method_handle_invoke = false); 21.33 21.34 CodeEmitInfo* next() const { return _next; } 21.35 void set_next(CodeEmitInfo* next) { _next = next; }
22.1 --- a/src/share/vm/c1/c1_Instruction.cpp Tue Mar 09 11:02:39 2010 -0800 22.2 +++ b/src/share/vm/c1/c1_Instruction.cpp Tue Mar 09 23:57:36 2010 -0800 22.3 @@ -1,5 +1,5 @@ 22.4 /* 22.5 - * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. 22.6 + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 22.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.8 * 22.9 * This code is free software; you can redistribute it and/or modify it 22.10 @@ -334,13 +334,14 @@ 22.11 22.12 22.13 Invoke::Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args, 22.14 - int vtable_index, ciMethod* target) 22.15 + int vtable_index, ciMethod* target, ValueStack* state_before) 22.16 : StateSplit(result_type) 22.17 , _code(code) 22.18 , _recv(recv) 22.19 , _args(args) 22.20 , _vtable_index(vtable_index) 22.21 , _target(target) 22.22 + , _state_before(state_before) 22.23 { 22.24 set_flag(TargetIsLoadedFlag, target->is_loaded()); 22.25 set_flag(TargetIsFinalFlag, target_is_loaded() && target->is_final_method()); 22.26 @@ -355,6 +356,9 @@ 22.27 _signature = new BasicTypeList(number_of_arguments() + (has_receiver() ? 1 : 0)); 22.28 if (has_receiver()) { 22.29 _signature->append(as_BasicType(receiver()->type())); 22.30 + } else if (is_invokedynamic()) { 22.31 + // Add the synthetic MethodHandle argument to the signature. 22.32 + _signature->append(T_OBJECT); 22.33 } 22.34 for (int i = 0; i < number_of_arguments(); i++) { 22.35 ValueType* t = argument_at(i)->type(); 22.36 @@ -364,6 +368,13 @@ 22.37 } 22.38 22.39 22.40 +void Invoke::state_values_do(void f(Value*)) { 22.41 + StateSplit::state_values_do(f); 22.42 + if (state_before() != NULL) state_before()->values_do(f); 22.43 + if (state() != NULL) state()->values_do(f); 22.44 +} 22.45 + 22.46 + 22.47 // Implementation of Contant 22.48 intx Constant::hash() const { 22.49 if (_state == NULL) {
23.1 --- a/src/share/vm/c1/c1_Instruction.hpp Tue Mar 09 11:02:39 2010 -0800 23.2 +++ b/src/share/vm/c1/c1_Instruction.hpp Tue Mar 09 23:57:36 2010 -0800 23.3 @@ -1,5 +1,5 @@ 23.4 /* 23.5 - * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. 23.6 + * Copyright 1999-2010 Sun Microsystems, Inc. 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 @@ -1134,17 +1134,18 @@ 23.11 23.12 LEAF(Invoke, StateSplit) 23.13 private: 23.14 - Bytecodes::Code _code; 23.15 - Value _recv; 23.16 - Values* _args; 23.17 - BasicTypeList* _signature; 23.18 - int _vtable_index; 23.19 - ciMethod* _target; 23.20 + Bytecodes::Code _code; 23.21 + Value _recv; 23.22 + Values* _args; 23.23 + BasicTypeList* _signature; 23.24 + int _vtable_index; 23.25 + ciMethod* _target; 23.26 + ValueStack* _state_before; // Required for deoptimization. 23.27 23.28 public: 23.29 // creation 23.30 Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args, 23.31 - int vtable_index, ciMethod* target); 23.32 + int vtable_index, ciMethod* target, ValueStack* state_before); 23.33 23.34 // accessors 23.35 Bytecodes::Code code() const { return _code; } 23.36 @@ -1155,6 +1156,7 @@ 23.37 int vtable_index() const { return _vtable_index; } 23.38 BasicTypeList* signature() const { return _signature; } 23.39 ciMethod* target() const { return _target; } 23.40 + ValueStack* state_before() const { return _state_before; } 23.41 23.42 // Returns false if target is not loaded 23.43 bool target_is_final() const { return check_flag(TargetIsFinalFlag); } 23.44 @@ -1162,6 +1164,9 @@ 23.45 // Returns false if target is not loaded 23.46 bool target_is_strictfp() const { return check_flag(TargetIsStrictfpFlag); } 23.47 23.48 + // JSR 292 support 23.49 + bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; } 23.50 + 23.51 // generic 23.52 virtual bool can_trap() const { return true; } 23.53 virtual void input_values_do(void f(Value*)) { 23.54 @@ -1169,6 +1174,7 @@ 23.55 if (has_receiver()) f(&_recv); 23.56 for (int i = 0; i < _args->length(); i++) f(_args->adr_at(i)); 23.57 } 23.58 + virtual void state_values_do(void f(Value*)); 23.59 }; 23.60 23.61
24.1 --- a/src/share/vm/c1/c1_LIR.cpp Tue Mar 09 11:02:39 2010 -0800 24.2 +++ b/src/share/vm/c1/c1_LIR.cpp Tue Mar 09 23:57:36 2010 -0800 24.3 @@ -1,5 +1,5 @@ 24.4 /* 24.5 - * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. 24.6 + * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved. 24.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 24.8 * 24.9 * This code is free software; you can redistribute it and/or modify it 24.10 @@ -689,9 +689,10 @@ 24.11 case lir_static_call: 24.12 case lir_optvirtual_call: 24.13 case lir_icvirtual_call: 24.14 - case lir_virtual_call: { 24.15 - assert(op->as_OpJavaCall() != NULL, "must be"); 24.16 - LIR_OpJavaCall* opJavaCall = (LIR_OpJavaCall*)op; 24.17 + case lir_virtual_call: 24.18 + case lir_dynamic_call: { 24.19 + LIR_OpJavaCall* opJavaCall = op->as_OpJavaCall(); 24.20 + assert(opJavaCall != NULL, "must be"); 24.21 24.22 if (opJavaCall->_receiver->is_valid()) do_input(opJavaCall->_receiver); 24.23 24.24 @@ -1590,6 +1591,7 @@ 24.25 case lir_optvirtual_call: s = "optvirtual"; break; 24.26 case lir_icvirtual_call: s = "icvirtual"; break; 24.27 case lir_virtual_call: s = "virtual"; break; 24.28 + case lir_dynamic_call: s = "dynamic"; break; 24.29 // LIR_OpArrayCopy 24.30 case lir_arraycopy: s = "arraycopy"; break; 24.31 // LIR_OpLock
25.1 --- a/src/share/vm/c1/c1_LIR.hpp Tue Mar 09 11:02:39 2010 -0800 25.2 +++ b/src/share/vm/c1/c1_LIR.hpp Tue Mar 09 23:57:36 2010 -0800 25.3 @@ -840,6 +840,7 @@ 25.4 , lir_optvirtual_call 25.5 , lir_icvirtual_call 25.6 , lir_virtual_call 25.7 + , lir_dynamic_call 25.8 , end_opJavaCall 25.9 , begin_opArrayCopy 25.10 , lir_arraycopy 25.11 @@ -1052,6 +1053,16 @@ 25.12 LIR_Opr receiver() const { return _receiver; } 25.13 ciMethod* method() const { return _method; } 25.14 25.15 + // JSR 292 support. 25.16 + bool is_invokedynamic() const { return code() == lir_dynamic_call; } 25.17 + bool is_method_handle_invoke() const { 25.18 + return 25.19 + is_invokedynamic() // An invokedynamic is always a MethodHandle call site. 25.20 + || 25.21 + (method()->holder()->name() == ciSymbol::java_dyn_MethodHandle() && 25.22 + method()->name() == ciSymbol::invoke_name()); 25.23 + } 25.24 + 25.25 intptr_t vtable_offset() const { 25.26 assert(_code == lir_virtual_call, "only have vtable for real vcall"); 25.27 return (intptr_t) addr(); 25.28 @@ -1766,6 +1777,10 @@ 25.29 intptr_t vtable_offset, LIR_OprList* arguments, CodeEmitInfo* info) { 25.30 append(new LIR_OpJavaCall(lir_virtual_call, method, receiver, result, vtable_offset, arguments, info)); 25.31 } 25.32 + void call_dynamic(ciMethod* method, LIR_Opr receiver, LIR_Opr result, 25.33 + address dest, LIR_OprList* arguments, CodeEmitInfo* info) { 25.34 + append(new LIR_OpJavaCall(lir_dynamic_call, method, receiver, result, dest, arguments, info)); 25.35 + } 25.36 25.37 void get_thread(LIR_Opr result) { append(new LIR_Op0(lir_get_thread, result)); } 25.38 void word_align() { append(new LIR_Op0(lir_word_align)); }
26.1 --- a/src/share/vm/c1/c1_LIRAssembler.cpp Tue Mar 09 11:02:39 2010 -0800 26.2 +++ b/src/share/vm/c1/c1_LIRAssembler.cpp Tue Mar 09 23:57:36 2010 -0800 26.3 @@ -1,5 +1,5 @@ 26.4 /* 26.5 - * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved. 26.6 + * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved. 26.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.8 * 26.9 * This code is free software; you can redistribute it and/or modify it 26.10 @@ -301,9 +301,9 @@ 26.11 } 26.12 26.13 26.14 -void LIR_Assembler::add_call_info(int pc_offset, CodeEmitInfo* cinfo) { 26.15 +void LIR_Assembler::add_call_info(int pc_offset, CodeEmitInfo* cinfo, bool is_method_handle_invoke) { 26.16 flush_debug_info(pc_offset); 26.17 - cinfo->record_debug_info(compilation()->debug_info_recorder(), pc_offset); 26.18 + cinfo->record_debug_info(compilation()->debug_info_recorder(), pc_offset, is_method_handle_invoke); 26.19 if (cinfo->exception_handlers() != NULL) { 26.20 compilation()->add_exception_handlers_for_pco(pc_offset, cinfo->exception_handlers()); 26.21 } 26.22 @@ -413,6 +413,12 @@ 26.23 void LIR_Assembler::emit_call(LIR_OpJavaCall* op) { 26.24 verify_oop_map(op->info()); 26.25 26.26 + // JSR 292 26.27 + // Preserve the SP over MethodHandle call sites. 26.28 + if (op->is_method_handle_invoke()) { 26.29 + preserve_SP(); 26.30 + } 26.31 + 26.32 if (os::is_MP()) { 26.33 // must align calls sites, otherwise they can't be updated atomically on MP hardware 26.34 align_call(op->code()); 26.35 @@ -423,19 +429,25 @@ 26.36 26.37 switch (op->code()) { 26.38 case lir_static_call: 26.39 - call(op->addr(), relocInfo::static_call_type, op->info()); 26.40 + call(op, relocInfo::static_call_type); 26.41 break; 26.42 case lir_optvirtual_call: 26.43 - call(op->addr(), relocInfo::opt_virtual_call_type, op->info()); 26.44 + case lir_dynamic_call: 26.45 + call(op, relocInfo::opt_virtual_call_type); 26.46 break; 26.47 case lir_icvirtual_call: 26.48 - ic_call(op->addr(), op->info()); 26.49 + ic_call(op); 26.50 break; 26.51 case lir_virtual_call: 26.52 - vtable_call(op->vtable_offset(), op->info()); 26.53 + vtable_call(op); 26.54 break; 26.55 default: ShouldNotReachHere(); 26.56 } 26.57 + 26.58 + if (op->is_method_handle_invoke()) { 26.59 + restore_SP(); 26.60 + } 26.61 + 26.62 #if defined(X86) && defined(TIERED) 26.63 // C2 leave fpu stack dirty clean it 26.64 if (UseSSE < 2) {
27.1 --- a/src/share/vm/c1/c1_LIRAssembler.hpp Tue Mar 09 11:02:39 2010 -0800 27.2 +++ b/src/share/vm/c1/c1_LIRAssembler.hpp Tue Mar 09 23:57:36 2010 -0800 27.3 @@ -82,7 +82,7 @@ 27.4 Address as_Address_hi(LIR_Address* addr); 27.5 27.6 // debug information 27.7 - void add_call_info(int pc_offset, CodeEmitInfo* cinfo); 27.8 + void add_call_info(int pc_offset, CodeEmitInfo* cinfo, bool is_method_handle_invoke = false); 27.9 void add_debug_info_for_branch(CodeEmitInfo* info); 27.10 void add_debug_info_for_div0(int pc_offset, CodeEmitInfo* cinfo); 27.11 void add_debug_info_for_div0_here(CodeEmitInfo* info); 27.12 @@ -205,9 +205,12 @@ 27.13 void comp_fl2i(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr result, LIR_Op2* op); 27.14 void cmove(LIR_Condition code, LIR_Opr left, LIR_Opr right, LIR_Opr result); 27.15 27.16 - void ic_call(address destination, CodeEmitInfo* info); 27.17 - void vtable_call(int vtable_offset, CodeEmitInfo* info); 27.18 - void call(address entry, relocInfo::relocType rtype, CodeEmitInfo* info); 27.19 + void call( LIR_OpJavaCall* op, relocInfo::relocType rtype); 27.20 + void ic_call( LIR_OpJavaCall* op); 27.21 + void vtable_call( LIR_OpJavaCall* op); 27.22 + 27.23 + void preserve_SP(); 27.24 + void restore_SP(); 27.25 27.26 void osr_entry(); 27.27
28.1 --- a/src/share/vm/c1/c1_LIRGenerator.cpp Tue Mar 09 11:02:39 2010 -0800 28.2 +++ b/src/share/vm/c1/c1_LIRGenerator.cpp Tue Mar 09 23:57:36 2010 -0800 28.3 @@ -2284,7 +2284,7 @@ 28.4 28.5 28.6 void LIRGenerator::invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list) { 28.7 - int i = x->has_receiver() ? 1 : 0; 28.8 + int i = (x->has_receiver() || x->is_invokedynamic()) ? 1 : 0; 28.9 for (; i < args->length(); i++) { 28.10 LIRItem* param = args->at(i); 28.11 LIR_Opr loc = arg_list->at(i); 28.12 @@ -2322,6 +2322,10 @@ 28.13 LIRItem* receiver = new LIRItem(x->receiver(), this); 28.14 argument_items->append(receiver); 28.15 } 28.16 + if (x->is_invokedynamic()) { 28.17 + // Insert a dummy for the synthetic MethodHandle argument. 28.18 + argument_items->append(NULL); 28.19 + } 28.20 int idx = x->has_receiver() ? 1 : 0; 28.21 for (int i = 0; i < x->number_of_arguments(); i++) { 28.22 LIRItem* param = new LIRItem(x->argument_at(i), this); 28.23 @@ -2371,6 +2375,10 @@ 28.24 28.25 CodeEmitInfo* info = state_for(x, x->state()); 28.26 28.27 + // invokedynamics can deoptimize. 28.28 + bool is_invokedynamic = x->code() == Bytecodes::_invokedynamic; 28.29 + CodeEmitInfo* deopt_info = is_invokedynamic ? state_for(x, x->state_before()) : NULL; 28.30 + 28.31 invoke_load_arguments(x, args, arg_list); 28.32 28.33 if (x->has_receiver()) { 28.34 @@ -2407,6 +2415,47 @@ 28.35 __ call_virtual(x->target(), receiver, result_register, vtable_offset, arg_list, info); 28.36 } 28.37 break; 28.38 + case Bytecodes::_invokedynamic: { 28.39 + ciBytecodeStream bcs(x->scope()->method()); 28.40 + bcs.force_bci(x->bci()); 28.41 + assert(bcs.cur_bc() == Bytecodes::_invokedynamic, "wrong stream"); 28.42 + ciCPCache* cpcache = bcs.get_cpcache(); 28.43 + 28.44 + // Get CallSite offset from constant pool cache pointer. 28.45 + int index = bcs.get_method_index(); 28.46 + size_t call_site_offset = cpcache->get_f1_offset(index); 28.47 + 28.48 + // If this invokedynamic call site hasn't been executed yet in 28.49 + // the interpreter, the CallSite object in the constant pool 28.50 + // cache is still null and we need to deoptimize. 28.51 + if (cpcache->is_f1_null_at(index)) { 28.52 + // Cannot re-use same xhandlers for multiple CodeEmitInfos, so 28.53 + // clone all handlers. This is handled transparently in other 28.54 + // places by the CodeEmitInfo cloning logic but is handled 28.55 + // specially here because a stub isn't being used. 28.56 + x->set_exception_handlers(new XHandlers(x->exception_handlers())); 28.57 + 28.58 + DeoptimizeStub* deopt_stub = new DeoptimizeStub(deopt_info); 28.59 + __ jump(deopt_stub); 28.60 + } 28.61 + 28.62 + // Use the receiver register for the synthetic MethodHandle 28.63 + // argument. 28.64 + receiver = LIR_Assembler::receiverOpr(); 28.65 + LIR_Opr tmp = new_register(objectType); 28.66 + 28.67 + // Load CallSite object from constant pool cache. 28.68 + __ oop2reg(cpcache->constant_encoding(), tmp); 28.69 + __ load(new LIR_Address(tmp, call_site_offset, T_OBJECT), tmp); 28.70 + 28.71 + // Load target MethodHandle from CallSite object. 28.72 + __ load(new LIR_Address(tmp, java_dyn_CallSite::target_offset_in_bytes(), T_OBJECT), receiver); 28.73 + 28.74 + __ call_dynamic(x->target(), receiver, result_register, 28.75 + SharedRuntime::get_resolve_opt_virtual_call_stub(), 28.76 + arg_list, info); 28.77 + break; 28.78 + } 28.79 default: 28.80 ShouldNotReachHere(); 28.81 break;
29.1 --- a/src/share/vm/c1/c1_MacroAssembler.hpp Tue Mar 09 11:02:39 2010 -0800 29.2 +++ b/src/share/vm/c1/c1_MacroAssembler.hpp Tue Mar 09 23:57:36 2010 -0800 29.3 @@ -1,5 +1,5 @@ 29.4 /* 29.5 - * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. 29.6 + * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved. 29.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.8 * 29.9 * This code is free software; you can redistribute it and/or modify it 29.10 @@ -34,7 +34,7 @@ 29.11 29.12 void inline_cache_check(Register receiver, Register iCache); 29.13 void build_frame(int frame_size_in_bytes); 29.14 - void method_exit(bool restore_frame); 29.15 + void remove_frame(int frame_size_in_bytes); 29.16 29.17 void unverified_entry(Register receiver, Register ic_klass); 29.18 void verified_entry();
30.1 --- a/src/share/vm/ci/ciCPCache.cpp Tue Mar 09 11:02:39 2010 -0800 30.2 +++ b/src/share/vm/ci/ciCPCache.cpp Tue Mar 09 23:57:36 2010 -0800 30.3 @@ -1,5 +1,5 @@ 30.4 /* 30.5 - * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 30.6 + * Copyright 2009-2010 Sun Microsystems, Inc. All Rights Reserved. 30.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.8 * 30.9 * This code is free software; you can redistribute it and/or modify it 30.10 @@ -41,6 +41,16 @@ 30.11 30.12 30.13 // ------------------------------------------------------------------ 30.14 +// ciCPCache::is_f1_null_at 30.15 +bool ciCPCache::is_f1_null_at(int index) { 30.16 + VM_ENTRY_MARK; 30.17 + constantPoolCacheOop cpcache = (constantPoolCacheOop) get_oop(); 30.18 + oop f1 = cpcache->secondary_entry_at(index)->f1(); 30.19 + return (f1 == NULL); 30.20 +} 30.21 + 30.22 + 30.23 +// ------------------------------------------------------------------ 30.24 // ciCPCache::print 30.25 // 30.26 // Print debugging information about the cache.
31.1 --- a/src/share/vm/ci/ciCPCache.hpp Tue Mar 09 11:02:39 2010 -0800 31.2 +++ b/src/share/vm/ci/ciCPCache.hpp Tue Mar 09 23:57:36 2010 -0800 31.3 @@ -1,5 +1,5 @@ 31.4 /* 31.5 - * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 31.6 + * Copyright 2009-2010 Sun Microsystems, Inc. All Rights Reserved. 31.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.8 * 31.9 * This code is free software; you can redistribute it and/or modify it 31.10 @@ -39,5 +39,7 @@ 31.11 // requested entry. 31.12 size_t get_f1_offset(int index); 31.13 31.14 + bool is_f1_null_at(int index); 31.15 + 31.16 void print(); 31.17 };
32.1 --- a/src/share/vm/includeDB_compiler1 Tue Mar 09 11:02:39 2010 -0800 32.2 +++ b/src/share/vm/includeDB_compiler1 Tue Mar 09 23:57:36 2010 -0800 32.3 @@ -1,5 +1,5 @@ 32.4 // 32.5 -// Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. 32.6 +// Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. 32.7 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.8 // 32.9 // This code is free software; you can redistribute it and/or modify it 32.10 @@ -246,6 +246,7 @@ 32.11 c1_LIRGenerator.cpp c1_LIRGenerator.hpp 32.12 c1_LIRGenerator.cpp c1_ValueStack.hpp 32.13 c1_LIRGenerator.cpp ciArrayKlass.hpp 32.14 +c1_LIRGenerator.cpp ciCPCache.hpp 32.15 c1_LIRGenerator.cpp ciInstance.hpp 32.16 c1_LIRGenerator.cpp heapRegion.hpp 32.17 c1_LIRGenerator.cpp sharedRuntime.hpp
33.1 --- a/src/share/vm/includeDB_core Tue Mar 09 11:02:39 2010 -0800 33.2 +++ b/src/share/vm/includeDB_core Tue Mar 09 23:57:36 2010 -0800 33.3 @@ -541,6 +541,7 @@ 33.4 33.5 ciCPCache.cpp cpCacheOop.hpp 33.6 ciCPCache.cpp ciCPCache.hpp 33.7 +ciCPCache.cpp ciUtilities.hpp 33.8 33.9 ciCPCache.hpp ciClassList.hpp 33.10 ciCPCache.hpp ciObject.hpp
34.1 --- a/src/share/vm/opto/runtime.cpp Tue Mar 09 11:02:39 2010 -0800 34.2 +++ b/src/share/vm/opto/runtime.cpp Tue Mar 09 23:57:36 2010 -0800 34.3 @@ -864,7 +864,7 @@ 34.4 thread->set_exception_handler_pc(handler_address); 34.5 thread->set_exception_stack_size(0); 34.6 34.7 - // Check if the exception PC is a MethodHandle call. 34.8 + // Check if the exception PC is a MethodHandle call site. 34.9 thread->set_is_method_handle_exception(nm->is_method_handle_return(pc)); 34.10 } 34.11 34.12 @@ -952,7 +952,7 @@ 34.13 34.14 thread->set_vm_result(exception); 34.15 // Frame not compiled (handles deoptimization blob) 34.16 - return SharedRuntime::raw_exception_handler_for_return_address(ret_pc); 34.17 + return SharedRuntime::raw_exception_handler_for_return_address(thread, ret_pc); 34.18 } 34.19 34.20
35.1 --- a/src/share/vm/runtime/sharedRuntime.cpp Tue Mar 09 11:02:39 2010 -0800 35.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp Tue Mar 09 23:57:36 2010 -0800 35.3 @@ -256,7 +256,7 @@ 35.4 // The continuation address is the entry point of the exception handler of the 35.5 // previous frame depending on the return address. 35.6 35.7 -address SharedRuntime::raw_exception_handler_for_return_address(address return_address) { 35.8 +address SharedRuntime::raw_exception_handler_for_return_address(JavaThread* thread, address return_address) { 35.9 assert(frame::verify_return_pc(return_address), "must be a return pc"); 35.10 35.11 // the fastest case first 35.12 @@ -264,6 +264,8 @@ 35.13 if (blob != NULL && blob->is_nmethod()) { 35.14 nmethod* code = (nmethod*)blob; 35.15 assert(code != NULL, "nmethod must be present"); 35.16 + // Check if the return address is a MethodHandle call site. 35.17 + thread->set_is_method_handle_exception(code->is_method_handle_return(return_address)); 35.18 // native nmethods don't have exception handlers 35.19 assert(!code->is_native_method(), "no exception handler"); 35.20 assert(code->header_begin() != code->exception_begin(), "no exception handler"); 35.21 @@ -289,6 +291,8 @@ 35.22 if (blob->is_nmethod()) { 35.23 nmethod* code = (nmethod*)blob; 35.24 assert(code != NULL, "nmethod must be present"); 35.25 + // Check if the return address is a MethodHandle call site. 35.26 + thread->set_is_method_handle_exception(code->is_method_handle_return(return_address)); 35.27 assert(code->header_begin() != code->exception_begin(), "no exception handler"); 35.28 return code->exception_begin(); 35.29 } 35.30 @@ -309,10 +313,11 @@ 35.31 } 35.32 35.33 35.34 -JRT_LEAF(address, SharedRuntime::exception_handler_for_return_address(address return_address)) 35.35 - return raw_exception_handler_for_return_address(return_address); 35.36 +JRT_LEAF(address, SharedRuntime::exception_handler_for_return_address(JavaThread* thread, address return_address)) 35.37 + return raw_exception_handler_for_return_address(thread, return_address); 35.38 JRT_END 35.39 35.40 + 35.41 address SharedRuntime::get_poll_stub(address pc) { 35.42 address stub; 35.43 // Look up the code blob 35.44 @@ -465,16 +470,6 @@ 35.45 t = table.entry_for(catch_pco, -1, 0); 35.46 } 35.47 35.48 -#ifdef COMPILER1 35.49 - if (nm->is_compiled_by_c1() && t == NULL && handler_bci == -1) { 35.50 - // Exception is not handled by this frame so unwind. Note that 35.51 - // this is not the same as how C2 does this. C2 emits a table 35.52 - // entry that dispatches to the unwind code in the nmethod. 35.53 - return NULL; 35.54 - } 35.55 -#endif /* COMPILER1 */ 35.56 - 35.57 - 35.58 if (t == NULL) { 35.59 tty->print_cr("MISSING EXCEPTION HANDLER for pc " INTPTR_FORMAT " and handler bci %d", ret_pc, handler_bci); 35.60 tty->print_cr(" Exception:"); 35.61 @@ -892,12 +887,13 @@ 35.62 RegisterMap cbl_map(thread, false); 35.63 frame caller_frame = thread->last_frame().sender(&cbl_map); 35.64 35.65 - CodeBlob* cb = caller_frame.cb(); 35.66 - guarantee(cb != NULL && cb->is_nmethod(), "must be called from nmethod"); 35.67 + CodeBlob* caller_cb = caller_frame.cb(); 35.68 + guarantee(caller_cb != NULL && caller_cb->is_nmethod(), "must be called from nmethod"); 35.69 + nmethod* caller_nm = caller_cb->as_nmethod_or_null(); 35.70 // make sure caller is not getting deoptimized 35.71 // and removed before we are done with it. 35.72 // CLEANUP - with lazy deopt shouldn't need this lock 35.73 - nmethodLocker caller_lock((nmethod*)cb); 35.74 + nmethodLocker caller_lock(caller_nm); 35.75 35.76 35.77 // determine call info & receiver 35.78 @@ -929,6 +925,13 @@ 35.79 } 35.80 #endif 35.81 35.82 + // JSR 292 35.83 + // If the resolved method is a MethodHandle invoke target the call 35.84 + // site must be a MethodHandle call site. 35.85 + if (callee_method->is_method_handle_invoke()) { 35.86 + assert(caller_nm->is_method_handle_return(caller_frame.pc()), "must be MH call site"); 35.87 + } 35.88 + 35.89 // Compute entry points. This might require generation of C2I converter 35.90 // frames, so we cannot be holding any locks here. Furthermore, the 35.91 // computation of the entry points is independent of patching the call. We 35.92 @@ -940,13 +943,12 @@ 35.93 StaticCallInfo static_call_info; 35.94 CompiledICInfo virtual_call_info; 35.95 35.96 - 35.97 // Make sure the callee nmethod does not get deoptimized and removed before 35.98 // we are done patching the code. 35.99 - nmethod* nm = callee_method->code(); 35.100 - nmethodLocker nl_callee(nm); 35.101 + nmethod* callee_nm = callee_method->code(); 35.102 + nmethodLocker nl_callee(callee_nm); 35.103 #ifdef ASSERT 35.104 - address dest_entry_point = nm == NULL ? 0 : nm->entry_point(); // used below 35.105 + address dest_entry_point = callee_nm == NULL ? 0 : callee_nm->entry_point(); // used below 35.106 #endif 35.107 35.108 if (is_virtual) {
36.1 --- a/src/share/vm/runtime/sharedRuntime.hpp Tue Mar 09 11:02:39 2010 -0800 36.2 +++ b/src/share/vm/runtime/sharedRuntime.hpp Tue Mar 09 23:57:36 2010 -0800 36.3 @@ -96,10 +96,9 @@ 36.4 static jdouble dexp(jdouble x); 36.5 static jdouble dpow(jdouble x, jdouble y); 36.6 36.7 - 36.8 // exception handling across interpreter/compiler boundaries 36.9 - static address raw_exception_handler_for_return_address(address return_address); 36.10 - static address exception_handler_for_return_address(address return_address); 36.11 + static address raw_exception_handler_for_return_address(JavaThread* thread, address return_address); 36.12 + static address exception_handler_for_return_address(JavaThread* thread, address return_address); 36.13 36.14 #ifndef SERIALGC 36.15 // G1 write barriers
37.1 --- a/src/share/vm/runtime/vframeArray.cpp Tue Mar 09 11:02:39 2010 -0800 37.2 +++ b/src/share/vm/runtime/vframeArray.cpp Tue Mar 09 23:57:36 2010 -0800 37.3 @@ -223,7 +223,7 @@ 37.4 break; 37.5 case Deoptimization::Unpack_exception: 37.6 // exception is pending 37.7 - pc = SharedRuntime::raw_exception_handler_for_return_address(pc); 37.8 + pc = SharedRuntime::raw_exception_handler_for_return_address(thread, pc); 37.9 // [phh] We're going to end up in some handler or other, so it doesn't 37.10 // matter what mdp we point to. See exception_handler_for_exception() 37.11 // in interpreterRuntime.cpp.