comparison src/cpu/sparc/vm/stubGenerator_sparc.cpp @ 727:6b2273dd6fa9

6822110: Add AddressLiteral class on SPARC Summary: The Address class on SPARC currently handles both, addresses and address literals, what makes the Address class more complicated than it has to be. Reviewed-by: never, kvn
author twisti
date Tue, 21 Apr 2009 11:16:30 -0700
parents d0994e5bebce
children ddb7834449d0
comparison
equal deleted inserted replaced
725:928912ce8438 727:6b2273dd6fa9
1 /* 1 /*
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
66 private: 66 private:
67 67
68 #ifdef PRODUCT 68 #ifdef PRODUCT
69 #define inc_counter_np(a,b,c) (0) 69 #define inc_counter_np(a,b,c) (0)
70 #else 70 #else
71 void inc_counter_np_(int& counter, Register t1, Register t2) {
72 Address counter_addr(t2, (address) &counter);
73 __ sethi(counter_addr);
74 __ ld(counter_addr, t1);
75 __ inc(t1);
76 __ st(t1, counter_addr);
77 }
78 #define inc_counter_np(counter, t1, t2) \ 71 #define inc_counter_np(counter, t1, t2) \
79 BLOCK_COMMENT("inc_counter " #counter); \ 72 BLOCK_COMMENT("inc_counter " #counter); \
80 inc_counter_np_(counter, t1, t2); 73 __ inc_counter(&counter, t1, t2);
81 #endif 74 #endif
82 75
83 //---------------------------------------------------------------------------------------------------- 76 //----------------------------------------------------------------------------------------------------
84 // Call stubs are used to call Java from C 77 // Call stubs are used to call Java from C
85 78
323 address start = __ pc(); 316 address start = __ pc();
324 // verify that thread corresponds 317 // verify that thread corresponds
325 __ verify_thread(); 318 __ verify_thread();
326 319
327 const Register& temp_reg = Gtemp; 320 const Register& temp_reg = Gtemp;
328 Address pending_exception_addr (G2_thread, 0, in_bytes(Thread::pending_exception_offset())); 321 Address pending_exception_addr (G2_thread, Thread::pending_exception_offset());
329 Address exception_file_offset_addr(G2_thread, 0, in_bytes(Thread::exception_file_offset ())); 322 Address exception_file_offset_addr(G2_thread, Thread::exception_file_offset ());
330 Address exception_line_offset_addr(G2_thread, 0, in_bytes(Thread::exception_line_offset ())); 323 Address exception_line_offset_addr(G2_thread, Thread::exception_line_offset ());
331 324
332 // set pending exception 325 // set pending exception
333 __ verify_oop(Oexception); 326 __ verify_oop(Oexception);
334 __ st_ptr(Oexception, pending_exception_addr); 327 __ st_ptr(Oexception, pending_exception_addr);
335 __ set((intptr_t)__FILE__, temp_reg); 328 __ set((intptr_t)__FILE__, temp_reg);
338 __ st(temp_reg, exception_line_offset_addr); 331 __ st(temp_reg, exception_line_offset_addr);
339 332
340 // complete return to VM 333 // complete return to VM
341 assert(StubRoutines::_call_stub_return_address != NULL, "must have been generated before"); 334 assert(StubRoutines::_call_stub_return_address != NULL, "must have been generated before");
342 335
343 Address stub_ret(temp_reg, StubRoutines::_call_stub_return_address); 336 AddressLiteral stub_ret(StubRoutines::_call_stub_return_address);
344 __ jump_to(stub_ret); 337 __ jump_to(stub_ret, temp_reg);
345 __ delayed()->nop(); 338 __ delayed()->nop();
346 339
347 return start; 340 return start;
348 } 341 }
349 342
364 // (interpreted or compiled) code; i.e. the return address 357 // (interpreted or compiled) code; i.e. the return address
365 // becomes the throwing pc. 358 // becomes the throwing pc.
366 359
367 const Register& handler_reg = Gtemp; 360 const Register& handler_reg = Gtemp;
368 361
369 Address exception_addr (G2_thread, 0, in_bytes(Thread::pending_exception_offset())); 362 Address exception_addr(G2_thread, Thread::pending_exception_offset());
370 363
371 #ifdef ASSERT 364 #ifdef ASSERT
372 // make sure that this code is only executed if there is a pending exception 365 // make sure that this code is only executed if there is a pending exception
373 { Label L; 366 { Label L;
374 __ ld_ptr(exception_addr, Gtemp); 367 __ ld_ptr(exception_addr, Gtemp);
454 __ save_frame(0); 447 __ save_frame(0);
455 448
456 int frame_complete = __ offset(); 449 int frame_complete = __ offset();
457 450
458 if (restore_saved_exception_pc) { 451 if (restore_saved_exception_pc) {
459 Address saved_exception_pc(G2_thread, 0, in_bytes(JavaThread::saved_exception_pc_offset())); 452 __ ld_ptr(G2_thread, JavaThread::saved_exception_pc_offset(), I7);
460 __ ld_ptr(saved_exception_pc, I7);
461 __ sub(I7, frame::pc_return_offset, I7); 453 __ sub(I7, frame::pc_return_offset, I7);
462 } 454 }
463 455
464 // Note that we always have a runtime stub frame on the top of stack by this point 456 // Note that we always have a runtime stub frame on the top of stack by this point
465 Register last_java_sp = SP; 457 Register last_java_sp = SP;
479 471
480 // check for pending exceptions. use Gtemp as scratch register. 472 // check for pending exceptions. use Gtemp as scratch register.
481 #ifdef ASSERT 473 #ifdef ASSERT
482 Label L; 474 Label L;
483 475
484 Address exception_addr(G2_thread, 0, in_bytes(Thread::pending_exception_offset())); 476 Address exception_addr(G2_thread, Thread::pending_exception_offset());
485 Register scratch_reg = Gtemp; 477 Register scratch_reg = Gtemp;
486 __ ld_ptr(exception_addr, scratch_reg); 478 __ ld_ptr(exception_addr, scratch_reg);
487 __ br_notnull(scratch_reg, false, Assembler::pt, L); 479 __ br_notnull(scratch_reg, false, Assembler::pt, L);
488 __ delayed()->nop(); 480 __ delayed()->nop();
489 __ should_not_reach_here(); 481 __ should_not_reach_here();
833 address generate_handler_for_unsafe_access() { 825 address generate_handler_for_unsafe_access() {
834 StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); 826 StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access");
835 address start = __ pc(); 827 address start = __ pc();
836 828
837 const int preserve_register_words = (64 * 2); 829 const int preserve_register_words = (64 * 2);
838 Address preserve_addr(FP, 0, (-preserve_register_words * wordSize) + STACK_BIAS); 830 Address preserve_addr(FP, (-preserve_register_words * wordSize) + STACK_BIAS);
839 831
840 Register Lthread = L7_thread_cache; 832 Register Lthread = L7_thread_cache;
841 int i; 833 int i;
842 834
843 __ save_frame(0); 835 __ save_frame(0);
1104 __ add(count, addr, count); 1096 __ add(count, addr, count);
1105 // Use two shifts to clear out those low order two bits! (Cannot opt. into 1.) 1097 // Use two shifts to clear out those low order two bits! (Cannot opt. into 1.)
1106 __ srl_ptr(addr, CardTableModRefBS::card_shift, addr); 1098 __ srl_ptr(addr, CardTableModRefBS::card_shift, addr);
1107 __ srl_ptr(count, CardTableModRefBS::card_shift, count); 1099 __ srl_ptr(count, CardTableModRefBS::card_shift, count);
1108 __ sub(count, addr, count); 1100 __ sub(count, addr, count);
1109 Address rs(tmp, (address)ct->byte_map_base); 1101 AddressLiteral rs(ct->byte_map_base);
1110 __ load_address(rs); 1102 __ set(rs, tmp);
1111 __ BIND(L_loop); 1103 __ BIND(L_loop);
1112 __ stb(G0, rs.base(), addr); 1104 __ stb(G0, tmp, addr);
1113 __ subcc(count, 1, count); 1105 __ subcc(count, 1, count);
1114 __ brx(Assembler::greaterEqual, false, Assembler::pt, L_loop); 1106 __ brx(Assembler::greaterEqual, false, Assembler::pt, L_loop);
1115 __ delayed()->add(addr, 1, addr); 1107 __ delayed()->add(addr, 1, addr);
1116 1108 }
1117 }
1118 break; 1109 break;
1119 case BarrierSet::ModRef: 1110 case BarrierSet::ModRef:
1120 break; 1111 break;
1121 default : 1112 default:
1122 ShouldNotReachHere(); 1113 ShouldNotReachHere();
1123
1124 } 1114 }
1125 } 1115 }
1126 1116
1127 1117
1128 // Copy big chunks forward with shift 1118 // Copy big chunks forward with shift