< prev index next >

src/hotspot/cpu/x86/c1_Runtime1_x86.cpp

Print this page

 189     pop(c_rarg3);
 190   } else {
 191     mov(c_rarg1, arg1);
 192     mov(c_rarg2, arg2);
 193     mov(c_rarg3, arg3);
 194   }
 195 #else
 196   push(arg3);
 197   push(arg2);
 198   push(arg1);
 199 #endif // _LP64
 200   return call_RT(oop_result1, metadata_result, entry, 3);
 201 }
 202 
 203 
 204 // Implementation of StubFrame
 205 
 206 class StubFrame: public StackObj {
 207  private:
 208   StubAssembler* _sasm;

 209 
 210  public:
 211   StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments);
 212   void load_argument(int offset_in_words, Register reg);
 213 
 214   ~StubFrame();
 215 };
 216 
 217 void StubAssembler::prologue(const char* name, bool must_gc_arguments) {
 218   set_info(name, must_gc_arguments);
 219   enter();
 220 }
 221 
 222 void StubAssembler::epilogue() {
 223   leave();
 224   ret(0);
 225 }
 226 
 227 #define __ _sasm->
 228 
 229 StubFrame::StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments) {
 230   _sasm = sasm;

 231   __ prologue(name, must_gc_arguments);
 232 }
 233 
 234 // load parameters that were stored with LIR_Assembler::store_parameter
 235 // Note: offsets for store_parameter and load_argument must match
 236 void StubFrame::load_argument(int offset_in_words, Register reg) {
 237   __ load_parameter(offset_in_words, reg);
 238 }
 239 
 240 
 241 StubFrame::~StubFrame() {
 242   __ epilogue();
 243 }
 244 
 245 #undef __
 246 
 247 
 248 // Implementation of Runtime1
 249 
 250 const int float_regs_as_doubles_size_in_slots = pd_nof_fpu_regs_frame_map * 2;
 251 const int xmm_regs_as_doubles_size_in_slots = FrameMap::nof_xmm_regs * 2;
 252 
 253 // Stack layout for saving/restoring  all the registers needed during a runtime
 254 // call (this includes deoptimization)
 255 // Note: note that users of this frame may well have arguments to some runtime
 256 // while these values are on the stack. These positions neglect those arguments
 257 // but the code in save_live_registers will take the argument count into
 258 // account.
 259 //
 260 #ifdef _LP64
 261   #define SLOT2(x) x,
 262   #define SLOT_PER_WORD 2

 605 
 606 static OopMap* save_live_registers(StubAssembler* sasm, int num_rt_args,
 607                                    bool save_fpu_registers = true) {
 608   __ save_live_registers_no_oop_map(save_fpu_registers);
 609   return generate_oop_map(sasm, num_rt_args, save_fpu_registers);
 610 }
 611 
 612 static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) {
 613   __ restore_live_registers(restore_fpu_registers);
 614 }
 615 
 616 static void restore_live_registers_except_rax(StubAssembler* sasm, bool restore_fpu_registers = true) {
 617   sasm->restore_live_registers_except_rax(restore_fpu_registers);
 618 }
 619 
 620 
 621 void Runtime1::initialize_pd() {
 622   // nothing to do
 623 }
 624 



 625 
 626 // Target: the entry point of the method that creates and posts the exception oop.
 627 // has_argument: true if the exception needs arguments (passed on the stack because
 628 //               registers must be preserved).
 629 OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) {
 630   // Preserve all registers.
 631   int num_rt_args = has_argument ? (2 + 1) : 1;
 632   OopMap* oop_map = save_live_registers(sasm, num_rt_args);
 633 
 634   // Now all registers are saved and can be used freely.
 635   // Verify that no old value is used accidentally.
 636   __ invalidate_registers(true, true, true, true, true, true);
 637 
 638   // Registers used by this stub.
 639   const Register temp_reg = rbx;
 640 
 641   // Load arguments for exception that are passed as arguments into the stub.
 642   if (has_argument) {
 643 #ifdef _LP64
 644     __ movptr(c_rarg1, Address(rbp, 2*BytesPerWord));

1282         __ pop(rcx);
1283         __ pop(rsi);
1284         __ pop(rdi);
1285         __ ret(0);
1286 
1287         __ bind(miss);
1288         __ movptr(Address(rsp, (result_off) * VMRegImpl::stack_slot_size), NULL_WORD); // result
1289         __ pop(rax);
1290         __ pop(rcx);
1291         __ pop(rsi);
1292         __ pop(rdi);
1293         __ ret(0);
1294       }
1295       break;
1296 
1297     case monitorenter_nofpu_id:
1298       save_fpu_registers = false;
1299       // fall through
1300     case monitorenter_id:
1301       {
1302         StubFrame f(sasm, "monitorenter", dont_gc_arguments);
1303         OopMap* map = save_live_registers(sasm, 3, save_fpu_registers);
1304 
1305         // Called with store_parameter and not C abi
1306 
1307         f.load_argument(1, rax); // rax,: object
1308         f.load_argument(0, rbx); // rbx,: lock address
1309 
1310         int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), rax, rbx);
1311 
1312         oop_maps = new OopMapSet();
1313         oop_maps->add_gc_map(call_offset, map);
1314         restore_live_registers(sasm, save_fpu_registers);
1315       }
1316       break;
1317 
1318     case monitorexit_nofpu_id:
1319       save_fpu_registers = false;
1320       // fall through
1321     case monitorexit_id:
1322       {

 189     pop(c_rarg3);
 190   } else {
 191     mov(c_rarg1, arg1);
 192     mov(c_rarg2, arg2);
 193     mov(c_rarg3, arg3);
 194   }
 195 #else
 196   push(arg3);
 197   push(arg2);
 198   push(arg1);
 199 #endif // _LP64
 200   return call_RT(oop_result1, metadata_result, entry, 3);
 201 }
 202 
 203 
 204 // Implementation of StubFrame
 205 
 206 class StubFrame: public StackObj {
 207  private:
 208   StubAssembler* _sasm;
 209   bool _use_pop_on_epilog;
 210 
 211  public:
 212   StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments, bool use_pop_on_epilog = false);
 213   void load_argument(int offset_in_words, Register reg);
 214 
 215   ~StubFrame();
 216 };
 217 
 218 void StubAssembler::prologue(const char* name, bool must_gc_arguments) {
 219   set_info(name, must_gc_arguments);
 220   enter();
 221 }
 222 
 223 void StubAssembler::epilogue(bool use_pop) {
 224   use_pop ? pop(rbp) : leave();
 225   ret(0);
 226 }
 227 
 228 #define __ _sasm->
 229 
 230 StubFrame::StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments, bool use_pop_on_epilog) {
 231   _sasm = sasm;
 232   _use_pop_on_epilog = use_pop_on_epilog;
 233   __ prologue(name, must_gc_arguments);
 234 }
 235 
 236 // load parameters that were stored with LIR_Assembler::store_parameter
 237 // Note: offsets for store_parameter and load_argument must match
 238 void StubFrame::load_argument(int offset_in_words, Register reg) {
 239   __ load_parameter(offset_in_words, reg);
 240 }
 241 
 242 
 243 StubFrame::~StubFrame() {
 244   __ epilogue(_use_pop_on_epilog);
 245 }
 246 
 247 #undef __
 248 
 249 
 250 // Implementation of Runtime1
 251 
 252 const int float_regs_as_doubles_size_in_slots = pd_nof_fpu_regs_frame_map * 2;
 253 const int xmm_regs_as_doubles_size_in_slots = FrameMap::nof_xmm_regs * 2;
 254 
 255 // Stack layout for saving/restoring  all the registers needed during a runtime
 256 // call (this includes deoptimization)
 257 // Note: note that users of this frame may well have arguments to some runtime
 258 // while these values are on the stack. These positions neglect those arguments
 259 // but the code in save_live_registers will take the argument count into
 260 // account.
 261 //
 262 #ifdef _LP64
 263   #define SLOT2(x) x,
 264   #define SLOT_PER_WORD 2

 607 
 608 static OopMap* save_live_registers(StubAssembler* sasm, int num_rt_args,
 609                                    bool save_fpu_registers = true) {
 610   __ save_live_registers_no_oop_map(save_fpu_registers);
 611   return generate_oop_map(sasm, num_rt_args, save_fpu_registers);
 612 }
 613 
 614 static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) {
 615   __ restore_live_registers(restore_fpu_registers);
 616 }
 617 
 618 static void restore_live_registers_except_rax(StubAssembler* sasm, bool restore_fpu_registers = true) {
 619   sasm->restore_live_registers_except_rax(restore_fpu_registers);
 620 }
 621 
 622 
 623 void Runtime1::initialize_pd() {
 624   // nothing to do
 625 }
 626 
 627 uint Runtime1::runtime_blob_current_thread_offset(frame f) {
 628   return r15_off / 2;
 629 }
 630 
 631 // Target: the entry point of the method that creates and posts the exception oop.
 632 // has_argument: true if the exception needs arguments (passed on the stack because
 633 //               registers must be preserved).
 634 OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) {
 635   // Preserve all registers.
 636   int num_rt_args = has_argument ? (2 + 1) : 1;
 637   OopMap* oop_map = save_live_registers(sasm, num_rt_args);
 638 
 639   // Now all registers are saved and can be used freely.
 640   // Verify that no old value is used accidentally.
 641   __ invalidate_registers(true, true, true, true, true, true);
 642 
 643   // Registers used by this stub.
 644   const Register temp_reg = rbx;
 645 
 646   // Load arguments for exception that are passed as arguments into the stub.
 647   if (has_argument) {
 648 #ifdef _LP64
 649     __ movptr(c_rarg1, Address(rbp, 2*BytesPerWord));

1287         __ pop(rcx);
1288         __ pop(rsi);
1289         __ pop(rdi);
1290         __ ret(0);
1291 
1292         __ bind(miss);
1293         __ movptr(Address(rsp, (result_off) * VMRegImpl::stack_slot_size), NULL_WORD); // result
1294         __ pop(rax);
1295         __ pop(rcx);
1296         __ pop(rsi);
1297         __ pop(rdi);
1298         __ ret(0);
1299       }
1300       break;
1301 
1302     case monitorenter_nofpu_id:
1303       save_fpu_registers = false;
1304       // fall through
1305     case monitorenter_id:
1306       {
1307         StubFrame f(sasm, "monitorenter", dont_gc_arguments, true /* use_pop_on_epilog */);
1308         OopMap* map = save_live_registers(sasm, 3, save_fpu_registers);
1309 
1310         // Called with store_parameter and not C abi
1311 
1312         f.load_argument(1, rax); // rax,: object
1313         f.load_argument(0, rbx); // rbx,: lock address
1314 
1315         int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), rax, rbx);
1316 
1317         oop_maps = new OopMapSet();
1318         oop_maps->add_gc_map(call_offset, map);
1319         restore_live_registers(sasm, save_fpu_registers);
1320       }
1321       break;
1322 
1323     case monitorexit_nofpu_id:
1324       save_fpu_registers = false;
1325       // fall through
1326     case monitorexit_id:
1327       {
< prev index next >