Mercurial > hg > graal-compiler
comparison src/cpu/sparc/vm/assembler_sparc.cpp @ 6275:957c266d8bc5
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Aug 2012 10:39:19 +0200 |
parents | 33df1aeaebbf 1d7922586cf6 |
children | e522a00b91aa |
comparison
equal
deleted
inserted
replaced
5891:fd8832ae511d | 6275:957c266d8bc5 |
---|---|
42 #include "gc_implementation/g1/heapRegion.hpp" | 42 #include "gc_implementation/g1/heapRegion.hpp" |
43 #endif | 43 #endif |
44 | 44 |
45 #ifdef PRODUCT | 45 #ifdef PRODUCT |
46 #define BLOCK_COMMENT(str) /* nothing */ | 46 #define BLOCK_COMMENT(str) /* nothing */ |
47 #define STOP(error) stop(error) | |
47 #else | 48 #else |
48 #define BLOCK_COMMENT(str) block_comment(str) | 49 #define BLOCK_COMMENT(str) block_comment(str) |
50 #define STOP(error) block_comment(error); stop(error) | |
49 #endif | 51 #endif |
50 | 52 |
51 // Convert the raw encoding form into the form expected by the | 53 // Convert the raw encoding form into the form expected by the |
52 // constructor for Address. | 54 // constructor for Address. |
53 Address Address::make_raw(int base, int index, int scale, int disp, bool disp_is_oop) { | 55 Address Address::make_raw(int base, int index, int scale, int disp, bool disp_is_oop) { |
990 // Verify that flags was zeroed on return to Java | 992 // Verify that flags was zeroed on return to Java |
991 Label PcOk; | 993 Label PcOk; |
992 save_frame(0); // to avoid clobbering O0 | 994 save_frame(0); // to avoid clobbering O0 |
993 ld_ptr(pc_addr, L0); | 995 ld_ptr(pc_addr, L0); |
994 br_null_short(L0, Assembler::pt, PcOk); | 996 br_null_short(L0, Assembler::pt, PcOk); |
995 stop("last_Java_pc not zeroed before leaving Java"); | 997 STOP("last_Java_pc not zeroed before leaving Java"); |
996 bind(PcOk); | 998 bind(PcOk); |
997 | 999 |
998 // Verify that flags was zeroed on return to Java | 1000 // Verify that flags was zeroed on return to Java |
999 Label FlagsOk; | 1001 Label FlagsOk; |
1000 ld(flags, L0); | 1002 ld(flags, L0); |
1001 tst(L0); | 1003 tst(L0); |
1002 br(Assembler::zero, false, Assembler::pt, FlagsOk); | 1004 br(Assembler::zero, false, Assembler::pt, FlagsOk); |
1003 delayed() -> restore(); | 1005 delayed() -> restore(); |
1004 stop("flags not zeroed before leaving Java"); | 1006 STOP("flags not zeroed before leaving Java"); |
1005 bind(FlagsOk); | 1007 bind(FlagsOk); |
1006 #endif /* ASSERT */ | 1008 #endif /* ASSERT */ |
1007 // | 1009 // |
1008 // When returning from calling out from Java mode the frame anchor's last_Java_pc | 1010 // When returning from calling out from Java mode the frame anchor's last_Java_pc |
1009 // will always be set to NULL. It is set here so that if we are doing a call to | 1011 // will always be set to NULL. It is set here so that if we are doing a call to |
1019 // Make sure that we have an odd stack | 1021 // Make sure that we have an odd stack |
1020 Label StackOk; | 1022 Label StackOk; |
1021 andcc(last_java_sp, 0x01, G0); | 1023 andcc(last_java_sp, 0x01, G0); |
1022 br(Assembler::notZero, false, Assembler::pt, StackOk); | 1024 br(Assembler::notZero, false, Assembler::pt, StackOk); |
1023 delayed()->nop(); | 1025 delayed()->nop(); |
1024 stop("Stack Not Biased in set_last_Java_frame"); | 1026 STOP("Stack Not Biased in set_last_Java_frame"); |
1025 bind(StackOk); | 1027 bind(StackOk); |
1026 #endif // ASSERT | 1028 #endif // ASSERT |
1027 assert( last_java_sp != G4_scratch, "bad register usage in set_last_Java_frame"); | 1029 assert( last_java_sp != G4_scratch, "bad register usage in set_last_Java_frame"); |
1028 add( last_java_sp, STACK_BIAS, G4_scratch ); | 1030 add( last_java_sp, STACK_BIAS, G4_scratch ); |
1029 st_ptr(G4_scratch, G2_thread, JavaThread::last_Java_sp_offset()); | 1031 st_ptr(G4_scratch, G2_thread, JavaThread::last_Java_sp_offset()); |
1648 relocate(breakpoint_Relocation::spec(breakpoint_Relocation::safepoint)); | 1650 relocate(breakpoint_Relocation::spec(breakpoint_Relocation::safepoint)); |
1649 } | 1651 } |
1650 | 1652 |
1651 | 1653 |
1652 void RegistersForDebugging::print(outputStream* s) { | 1654 void RegistersForDebugging::print(outputStream* s) { |
1655 FlagSetting fs(Debugging, true); | |
1653 int j; | 1656 int j; |
1654 for ( j = 0; j < 8; ++j ) | 1657 for (j = 0; j < 8; ++j) { |
1655 if ( j != 6 ) s->print_cr("i%d = 0x%.16lx", j, i[j]); | 1658 if (j != 6) { s->print("i%d = ", j); os::print_location(s, i[j]); } |
1656 else s->print_cr( "fp = 0x%.16lx", i[j]); | 1659 else { s->print( "fp = " ); os::print_location(s, i[j]); } |
1660 } | |
1657 s->cr(); | 1661 s->cr(); |
1658 | 1662 |
1659 for ( j = 0; j < 8; ++j ) | 1663 for (j = 0; j < 8; ++j) { |
1660 s->print_cr("l%d = 0x%.16lx", j, l[j]); | 1664 s->print("l%d = ", j); os::print_location(s, l[j]); |
1665 } | |
1661 s->cr(); | 1666 s->cr(); |
1662 | 1667 |
1663 for ( j = 0; j < 8; ++j ) | 1668 for (j = 0; j < 8; ++j) { |
1664 if ( j != 6 ) s->print_cr("o%d = 0x%.16lx", j, o[j]); | 1669 if (j != 6) { s->print("o%d = ", j); os::print_location(s, o[j]); } |
1665 else s->print_cr( "sp = 0x%.16lx", o[j]); | 1670 else { s->print( "sp = " ); os::print_location(s, o[j]); } |
1671 } | |
1666 s->cr(); | 1672 s->cr(); |
1667 | 1673 |
1668 for ( j = 0; j < 8; ++j ) | 1674 for (j = 0; j < 8; ++j) { |
1669 s->print_cr("g%d = 0x%.16lx", j, g[j]); | 1675 s->print("g%d = ", j); os::print_location(s, g[j]); |
1676 } | |
1670 s->cr(); | 1677 s->cr(); |
1671 | 1678 |
1672 // print out floats with compression | 1679 // print out floats with compression |
1673 for (j = 0; j < 32; ) { | 1680 for (j = 0; j < 32; ) { |
1674 jfloat val = f[j]; | 1681 jfloat val = f[j]; |
2018 // Use the flag ShowMessageBoxOnError | 2025 // Use the flag ShowMessageBoxOnError |
2019 | 2026 |
2020 char* b = new char[1024]; | 2027 char* b = new char[1024]; |
2021 sprintf(b, "untested: %s", what); | 2028 sprintf(b, "untested: %s", what); |
2022 | 2029 |
2023 if ( ShowMessageBoxOnError ) stop(b); | 2030 if (ShowMessageBoxOnError) { STOP(b); } |
2024 else warn(b); | 2031 else { warn(b); } |
2025 } | 2032 } |
2026 | 2033 |
2027 | 2034 |
2028 void MacroAssembler::stop_subroutine() { | 2035 void MacroAssembler::stop_subroutine() { |
2029 RegistersForDebugging::save_registers(this); | 2036 RegistersForDebugging::save_registers(this); |
2996 lduw(scan_temp, ito_offset, scan_temp); | 3003 lduw(scan_temp, ito_offset, scan_temp); |
2997 ld_ptr(recv_klass, scan_temp, method_result); | 3004 ld_ptr(recv_klass, scan_temp, method_result); |
2998 } | 3005 } |
2999 | 3006 |
3000 | 3007 |
3008 // virtual method calling | |
3009 void MacroAssembler::lookup_virtual_method(Register recv_klass, | |
3010 RegisterOrConstant vtable_index, | |
3011 Register method_result) { | |
3012 assert_different_registers(recv_klass, method_result, vtable_index.register_or_noreg()); | |
3013 Register sethi_temp = method_result; | |
3014 const int base = (instanceKlass::vtable_start_offset() * wordSize + | |
3015 // method pointer offset within the vtable entry: | |
3016 vtableEntry::method_offset_in_bytes()); | |
3017 RegisterOrConstant vtable_offset = vtable_index; | |
3018 // Each of the following three lines potentially generates an instruction. | |
3019 // But the total number of address formation instructions will always be | |
3020 // at most two, and will often be zero. In any case, it will be optimal. | |
3021 // If vtable_index is a register, we will have (sll_ptr N,x; inc_ptr B,x; ld_ptr k,x). | |
3022 // If vtable_index is a constant, we will have at most (set B+X<<N,t; ld_ptr k,t). | |
3023 vtable_offset = regcon_sll_ptr(vtable_index, exact_log2(vtableEntry::size() * wordSize), vtable_offset); | |
3024 vtable_offset = regcon_inc_ptr(vtable_offset, base, vtable_offset, sethi_temp); | |
3025 Address vtable_entry_addr(recv_klass, ensure_simm13_or_reg(vtable_offset, sethi_temp)); | |
3026 ld_ptr(vtable_entry_addr, method_result); | |
3027 } | |
3028 | |
3029 | |
3001 void MacroAssembler::check_klass_subtype(Register sub_klass, | 3030 void MacroAssembler::check_klass_subtype(Register sub_klass, |
3002 Register super_klass, | 3031 Register super_klass, |
3003 Register temp_reg, | 3032 Register temp_reg, |
3004 Register temp2_reg, | 3033 Register temp2_reg, |
3005 Label& L_success) { | 3034 Label& L_success) { |
3006 Label L_failure, L_pop_to_failure; | |
3007 check_klass_subtype_fast_path(sub_klass, super_klass, | |
3008 temp_reg, temp2_reg, | |
3009 &L_success, &L_failure, NULL); | |
3010 Register sub_2 = sub_klass; | 3035 Register sub_2 = sub_klass; |
3011 Register sup_2 = super_klass; | 3036 Register sup_2 = super_klass; |
3012 if (!sub_2->is_global()) sub_2 = L0; | 3037 if (!sub_2->is_global()) sub_2 = L0; |
3013 if (!sup_2->is_global()) sup_2 = L1; | 3038 if (!sup_2->is_global()) sup_2 = L1; |
3014 | 3039 bool did_save = false; |
3015 save_frame_and_mov(0, sub_klass, sub_2, super_klass, sup_2); | 3040 if (temp_reg == noreg || temp2_reg == noreg) { |
3041 temp_reg = L2; | |
3042 temp2_reg = L3; | |
3043 save_frame_and_mov(0, sub_klass, sub_2, super_klass, sup_2); | |
3044 sub_klass = sub_2; | |
3045 super_klass = sup_2; | |
3046 did_save = true; | |
3047 } | |
3048 Label L_failure, L_pop_to_failure, L_pop_to_success; | |
3049 check_klass_subtype_fast_path(sub_klass, super_klass, | |
3050 temp_reg, temp2_reg, | |
3051 (did_save ? &L_pop_to_success : &L_success), | |
3052 (did_save ? &L_pop_to_failure : &L_failure), NULL); | |
3053 | |
3054 if (!did_save) | |
3055 save_frame_and_mov(0, sub_klass, sub_2, super_klass, sup_2); | |
3016 check_klass_subtype_slow_path(sub_2, sup_2, | 3056 check_klass_subtype_slow_path(sub_2, sup_2, |
3017 L2, L3, L4, L5, | 3057 L2, L3, L4, L5, |
3018 NULL, &L_pop_to_failure); | 3058 NULL, &L_pop_to_failure); |
3019 | 3059 |
3020 // on success: | 3060 // on success: |
3061 bind(L_pop_to_success); | |
3021 restore(); | 3062 restore(); |
3022 ba_short(L_success); | 3063 ba_short(L_success); |
3023 | 3064 |
3024 // on failure: | 3065 // on failure: |
3025 bind(L_pop_to_failure); | 3066 bind(L_pop_to_failure); |
3232 | 3273 |
3233 bind(L_fallthrough); | 3274 bind(L_fallthrough); |
3234 } | 3275 } |
3235 | 3276 |
3236 | 3277 |
3237 void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg, | |
3238 Register temp_reg, | |
3239 Label& wrong_method_type) { | |
3240 assert_different_registers(mtype_reg, mh_reg, temp_reg); | |
3241 // compare method type against that of the receiver | |
3242 RegisterOrConstant mhtype_offset = delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg); | |
3243 load_heap_oop(mh_reg, mhtype_offset, temp_reg); | |
3244 cmp_and_brx_short(temp_reg, mtype_reg, Assembler::notEqual, Assembler::pn, wrong_method_type); | |
3245 } | |
3246 | |
3247 | |
3248 // A method handle has a "vmslots" field which gives the size of its | |
3249 // argument list in JVM stack slots. This field is either located directly | |
3250 // in every method handle, or else is indirectly accessed through the | |
3251 // method handle's MethodType. This macro hides the distinction. | |
3252 void MacroAssembler::load_method_handle_vmslots(Register vmslots_reg, Register mh_reg, | |
3253 Register temp_reg) { | |
3254 assert_different_registers(vmslots_reg, mh_reg, temp_reg); | |
3255 // load mh.type.form.vmslots | |
3256 Register temp2_reg = vmslots_reg; | |
3257 load_heap_oop(Address(mh_reg, delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg)), temp2_reg); | |
3258 load_heap_oop(Address(temp2_reg, delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, temp_reg)), temp2_reg); | |
3259 ld( Address(temp2_reg, delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg); | |
3260 } | |
3261 | |
3262 | |
3263 void MacroAssembler::jump_to_method_handle_entry(Register mh_reg, Register temp_reg, bool emit_delayed_nop) { | |
3264 assert(mh_reg == G3_method_handle, "caller must put MH object in G3"); | |
3265 assert_different_registers(mh_reg, temp_reg); | |
3266 | |
3267 // pick out the interpreted side of the handler | |
3268 // NOTE: vmentry is not an oop! | |
3269 ld_ptr(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes, temp_reg), temp_reg); | |
3270 | |
3271 // off we go... | |
3272 ld_ptr(temp_reg, MethodHandleEntry::from_interpreted_entry_offset_in_bytes(), temp_reg); | |
3273 jmp(temp_reg, 0); | |
3274 | |
3275 // for the various stubs which take control at this point, | |
3276 // see MethodHandles::generate_method_handle_stub | |
3277 | |
3278 // Some callers can fill the delay slot. | |
3279 if (emit_delayed_nop) { | |
3280 delayed()->nop(); | |
3281 } | |
3282 } | |
3283 | |
3284 | |
3285 RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot, | 3278 RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot, |
3286 Register temp_reg, | 3279 Register temp_reg, |
3287 int extra_slot_offset) { | 3280 int extra_slot_offset) { |
3288 // cf. TemplateTable::prepare_invoke(), if (load_receiver). | 3281 // cf. TemplateTable::prepare_invoke(), if (load_receiver). |
3289 int stackElementSize = Interpreter::stackElementSize; | 3282 int stackElementSize = Interpreter::stackElementSize; |
3912 save_frame(0); | 3905 save_frame(0); |
3913 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1); | 3906 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1); |
3914 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t2); | 3907 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t2); |
3915 or3(t1, t2, t3); | 3908 or3(t1, t2, t3); |
3916 cmp_and_br_short(t1, t2, Assembler::greaterEqual, Assembler::pn, next); | 3909 cmp_and_br_short(t1, t2, Assembler::greaterEqual, Assembler::pn, next); |
3917 stop("assert(top >= start)"); | 3910 STOP("assert(top >= start)"); |
3918 should_not_reach_here(); | 3911 should_not_reach_here(); |
3919 | 3912 |
3920 bind(next); | 3913 bind(next); |
3921 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1); | 3914 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1); |
3922 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t2); | 3915 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t2); |
3923 or3(t3, t2, t3); | 3916 or3(t3, t2, t3); |
3924 cmp_and_br_short(t1, t2, Assembler::lessEqual, Assembler::pn, next2); | 3917 cmp_and_br_short(t1, t2, Assembler::lessEqual, Assembler::pn, next2); |
3925 stop("assert(top <= end)"); | 3918 STOP("assert(top <= end)"); |
3926 should_not_reach_here(); | 3919 should_not_reach_here(); |
3927 | 3920 |
3928 bind(next2); | 3921 bind(next2); |
3929 and3(t3, MinObjAlignmentInBytesMask, t3); | 3922 and3(t3, MinObjAlignmentInBytesMask, t3); |
3930 cmp_and_br_short(t3, 0, Assembler::lessEqual, Assembler::pn, ok); | 3923 cmp_and_br_short(t3, 0, Assembler::lessEqual, Assembler::pn, ok); |
3931 stop("assert(aligned)"); | 3924 STOP("assert(aligned)"); |
3932 should_not_reach_here(); | 3925 should_not_reach_here(); |
3933 | 3926 |
3934 bind(ok); | 3927 bind(ok); |
3935 restore(); | 3928 restore(); |
3936 } | 3929 } |
3974 { | 3967 { |
3975 Label L; | 3968 Label L; |
3976 btst(MinObjAlignmentInBytesMask, obj); | 3969 btst(MinObjAlignmentInBytesMask, obj); |
3977 br(Assembler::zero, false, Assembler::pt, L); | 3970 br(Assembler::zero, false, Assembler::pt, L); |
3978 delayed()->nop(); | 3971 delayed()->nop(); |
3979 stop("eden top is not properly aligned"); | 3972 STOP("eden top is not properly aligned"); |
3980 bind(L); | 3973 bind(L); |
3981 } | 3974 } |
3982 #endif // ASSERT | 3975 #endif // ASSERT |
3983 const Register free = end; | 3976 const Register free = end; |
3984 sub(end, obj, free); // compute amount of free space | 3977 sub(end, obj, free); // compute amount of free space |
4011 set((intx)ch->top_addr(), top_addr); | 4004 set((intx)ch->top_addr(), top_addr); |
4012 ld_ptr(top_addr, 0, top_addr); | 4005 ld_ptr(top_addr, 0, top_addr); |
4013 btst(MinObjAlignmentInBytesMask, top_addr); | 4006 btst(MinObjAlignmentInBytesMask, top_addr); |
4014 br(Assembler::zero, false, Assembler::pt, L); | 4007 br(Assembler::zero, false, Assembler::pt, L); |
4015 delayed()->nop(); | 4008 delayed()->nop(); |
4016 stop("eden top is not properly aligned"); | 4009 STOP("eden top is not properly aligned"); |
4017 bind(L); | 4010 bind(L); |
4018 } | 4011 } |
4019 #endif // ASSERT | 4012 #endif // ASSERT |
4020 } | 4013 } |
4021 } | 4014 } |
4064 { | 4057 { |
4065 Label L; | 4058 Label L; |
4066 btst(MinObjAlignmentInBytesMask, free); | 4059 btst(MinObjAlignmentInBytesMask, free); |
4067 br(Assembler::zero, false, Assembler::pt, L); | 4060 br(Assembler::zero, false, Assembler::pt, L); |
4068 delayed()->nop(); | 4061 delayed()->nop(); |
4069 stop("updated TLAB free is not properly aligned"); | 4062 STOP("updated TLAB free is not properly aligned"); |
4070 bind(L); | 4063 bind(L); |
4071 } | 4064 } |
4072 #endif // ASSERT | 4065 #endif // ASSERT |
4073 | 4066 |
4074 // update the tlab top pointer | 4067 // update the tlab top pointer |
4162 { | 4155 { |
4163 Label ok; | 4156 Label ok; |
4164 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t2); | 4157 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t2); |
4165 sll_ptr(t2, LogHeapWordSize, t2); | 4158 sll_ptr(t2, LogHeapWordSize, t2); |
4166 cmp_and_br_short(t1, t2, Assembler::equal, Assembler::pt, ok); | 4159 cmp_and_br_short(t1, t2, Assembler::equal, Assembler::pt, ok); |
4167 stop("assert(t1 == tlab_size)"); | 4160 STOP("assert(t1 == tlab_size)"); |
4168 should_not_reach_here(); | 4161 should_not_reach_here(); |
4169 | 4162 |
4170 bind(ok); | 4163 bind(ok); |
4171 } | 4164 } |
4172 #endif // ASSERT | 4165 #endif // ASSERT |