src/cpu/x86/vm/x86_32.ad
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/cpu/x86/vm

src/cpu/x86/vm/x86_32.ad

Print this page
rev 6132 : 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
Summary: make compiled code bang the stack by the worst case size of the interpreter frame at deoptimization points.
Reviewed-by:


 495 void MachConstantBaseNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const {
 496   // Empty encoding
 497 }
 498 
 499 uint MachConstantBaseNode::size(PhaseRegAlloc* ra_) const {
 500   return 0;
 501 }
 502 
 503 #ifndef PRODUCT
 504 void MachConstantBaseNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
 505   st->print("# MachConstantBaseNode (empty encoding)");
 506 }
 507 #endif
 508 
 509 
 510 //=============================================================================
 511 #ifndef PRODUCT
 512 void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
 513   Compile* C = ra_->C;
 514 
 515   int framesize = C->frame_slots() << LogBytesPerInt;

 516   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
 517   // Remove wordSize for return addr which is already pushed.
 518   framesize -= wordSize;
 519 
 520   if (C->need_stack_bang(framesize)) {
 521     framesize -= wordSize;
 522     st->print("# stack bang");
 523     st->print("\n\t");
 524     st->print("PUSH   EBP\t# Save EBP");
 525     if (framesize) {
 526       st->print("\n\t");
 527       st->print("SUB    ESP, #%d\t# Create frame",framesize);
 528     }
 529   } else {
 530     st->print("SUB    ESP, #%d\t# Create frame",framesize);
 531     st->print("\n\t");
 532     framesize -= wordSize;
 533     st->print("MOV    [ESP + #%d], EBP\t# Save EBP",framesize);
 534   }
 535 
 536   if (VerifyStackAtCalls) {
 537     st->print("\n\t");
 538     framesize -= wordSize;
 539     st->print("MOV    [ESP + #%d], 0xBADB100D\t# Majik cookie for stack depth check",framesize);
 540   }
 541 
 542   if( C->in_24_bit_fp_mode() ) {


 546   if (UseSSE >= 2 && VerifyFPU) {
 547     st->print("\n\t");
 548     st->print("# verify FPU stack (must be clean on entry)");
 549   }
 550 
 551 #ifdef ASSERT
 552   if (VerifyStackAtCalls) {
 553     st->print("\n\t");
 554     st->print("# stack alignment check");
 555   }
 556 #endif
 557   st->cr();
 558 }
 559 #endif
 560 
 561 
 562 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
 563   Compile* C = ra_->C;
 564   MacroAssembler _masm(&cbuf);
 565 
 566   int framesize = C->frame_slots() << LogBytesPerInt;

 567 
 568   __ verified_entry(framesize, C->need_stack_bang(framesize), C->in_24_bit_fp_mode());
 569 
 570   C->set_frame_complete(cbuf.insts_size());
 571 
 572   if (C->has_mach_constant_base_node()) {
 573     // NOTE: We set the table base offset here because users might be
 574     // emitted before MachConstantBaseNode.
 575     Compile::ConstantTable& constant_table = C->constant_table();
 576     constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
 577   }
 578 }
 579 
 580 uint MachPrologNode::size(PhaseRegAlloc *ra_) const {
 581   return MachNode::size(ra_); // too many variables; just compute it the hard way
 582 }
 583 
 584 int MachPrologNode::reloc() const {
 585   return 0; // a large enough number
 586 }
 587 
 588 //=============================================================================
 589 #ifndef PRODUCT
 590 void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const {
 591   Compile *C = ra_->C;
 592   int framesize = C->frame_slots() << LogBytesPerInt;
 593   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
 594   // Remove two words for return addr and rbp,
 595   framesize -= 2*wordSize;
 596 
 597   if (C->max_vector_size() > 16) {
 598     st->print("VZEROUPPER");
 599     st->cr(); st->print("\t");
 600   }
 601   if (C->in_24_bit_fp_mode()) {
 602     st->print("FLDCW  standard control word");
 603     st->cr(); st->print("\t");
 604   }
 605   if (framesize) {
 606     st->print("ADD    ESP,%d\t# Destroy frame",framesize);
 607     st->cr(); st->print("\t");
 608   }
 609   st->print_cr("POPL   EBP"); st->print("\t");
 610   if (do_polling() && C->is_method_compilation()) {
 611     st->print("TEST   PollPage,EAX\t! Poll Safepoint");
 612     st->cr(); st->print("\t");
 613   }
 614 }
 615 #endif
 616 
 617 void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
 618   Compile *C = ra_->C;
 619 
 620   if (C->max_vector_size() > 16) {
 621     // Clear upper bits of YMM registers when current compiled code uses
 622     // wide vectors to avoid AVX <-> SSE transition penalty during call.
 623     MacroAssembler masm(&cbuf);
 624     masm.vzeroupper();
 625   }
 626   // If method set FPU control word, restore to standard control word
 627   if (C->in_24_bit_fp_mode()) {
 628     MacroAssembler masm(&cbuf);
 629     masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
 630   }
 631 
 632   int framesize = C->frame_slots() << LogBytesPerInt;
 633   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
 634   // Remove two words for return addr and rbp,
 635   framesize -= 2*wordSize;
 636 
 637   // Note that VerifyStackAtCalls' Majik cookie does not change the frame size popped here
 638 
 639   if (framesize >= 128) {
 640     emit_opcode(cbuf, 0x81); // add  SP, #framesize
 641     emit_rm(cbuf, 0x3, 0x00, ESP_enc);
 642     emit_d32(cbuf, framesize);
 643   } else if (framesize) {
 644     emit_opcode(cbuf, 0x83); // add  SP, #framesize
 645     emit_rm(cbuf, 0x3, 0x00, ESP_enc);
 646     emit_d8(cbuf, framesize);
 647   }
 648 
 649   emit_opcode(cbuf, 0x58 | EBP_enc);
 650 
 651   if (do_polling() && C->is_method_compilation()) {
 652     cbuf.relocate(cbuf.insts_end(), relocInfo::poll_return_type, 0);
 653     emit_opcode(cbuf,0x85);
 654     emit_rm(cbuf, 0x0, EAX_enc, 0x5); // EAX
 655     emit_d32(cbuf, (intptr_t)os::get_polling_page());
 656   }
 657 }
 658 
 659 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const {
 660   Compile *C = ra_->C;
 661   // If method set FPU control word, restore to standard control word
 662   int size = C->in_24_bit_fp_mode() ? 6 : 0;
 663   if (C->max_vector_size() > 16) size += 3; // vzeroupper
 664   if (do_polling() && C->is_method_compilation()) size += 6;
 665 
 666   int framesize = C->frame_slots() << LogBytesPerInt;
 667   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
 668   // Remove two words for return addr and rbp,
 669   framesize -= 2*wordSize;
 670 
 671   size++; // popl rbp,
 672 
 673   if (framesize >= 128) {
 674     size += 6;
 675   } else {
 676     size += framesize ? 3 : 0;
 677   }
 678   return size;
 679 }
 680 
 681 int MachEpilogNode::reloc() const {
 682   return 0; // a large enough number
 683 }
 684 
 685 const Pipeline * MachEpilogNode::pipeline() const {
 686   return MachNode::pipeline_class();




 495 void MachConstantBaseNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const {
 496   // Empty encoding
 497 }
 498 
 499 uint MachConstantBaseNode::size(PhaseRegAlloc* ra_) const {
 500   return 0;
 501 }
 502 
 503 #ifndef PRODUCT
 504 void MachConstantBaseNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
 505   st->print("# MachConstantBaseNode (empty encoding)");
 506 }
 507 #endif
 508 
 509 
 510 //=============================================================================
 511 #ifndef PRODUCT
 512 void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
 513   Compile* C = ra_->C;
 514 
 515   int framesize = C->frame_size_in_bytes();
 516   int bangsize = C->bang_size_in_bytes();
 517   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
 518   // Remove wordSize for return addr which is already pushed.
 519   framesize -= wordSize;
 520 
 521   if (C->need_stack_bang(bangsize)) {
 522     framesize -= wordSize;
 523     st->print("# stack bang (%d bytes)", bangsize);
 524     st->print("\n\t");
 525     st->print("PUSH   EBP\t# Save EBP");
 526     if (framesize) {
 527       st->print("\n\t");
 528       st->print("SUB    ESP, #%d\t# Create frame",framesize);
 529     }
 530   } else {
 531     st->print("SUB    ESP, #%d\t# Create frame",framesize);
 532     st->print("\n\t");
 533     framesize -= wordSize;
 534     st->print("MOV    [ESP + #%d], EBP\t# Save EBP",framesize);
 535   }
 536 
 537   if (VerifyStackAtCalls) {
 538     st->print("\n\t");
 539     framesize -= wordSize;
 540     st->print("MOV    [ESP + #%d], 0xBADB100D\t# Majik cookie for stack depth check",framesize);
 541   }
 542 
 543   if( C->in_24_bit_fp_mode() ) {


 547   if (UseSSE >= 2 && VerifyFPU) {
 548     st->print("\n\t");
 549     st->print("# verify FPU stack (must be clean on entry)");
 550   }
 551 
 552 #ifdef ASSERT
 553   if (VerifyStackAtCalls) {
 554     st->print("\n\t");
 555     st->print("# stack alignment check");
 556   }
 557 #endif
 558   st->cr();
 559 }
 560 #endif
 561 
 562 
 563 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
 564   Compile* C = ra_->C;
 565   MacroAssembler _masm(&cbuf);
 566 
 567   int framesize = C->frame_size_in_bytes();
 568   int bangsize = C->bang_size_in_bytes();
 569 
 570   __ verified_entry(framesize, C->need_stack_bang(bangsize)?bangsize:0, C->in_24_bit_fp_mode());
 571 
 572   C->set_frame_complete(cbuf.insts_size());
 573 
 574   if (C->has_mach_constant_base_node()) {
 575     // NOTE: We set the table base offset here because users might be
 576     // emitted before MachConstantBaseNode.
 577     Compile::ConstantTable& constant_table = C->constant_table();
 578     constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
 579   }
 580 }
 581 
 582 uint MachPrologNode::size(PhaseRegAlloc *ra_) const {
 583   return MachNode::size(ra_); // too many variables; just compute it the hard way
 584 }
 585 
 586 int MachPrologNode::reloc() const {
 587   return 0; // a large enough number
 588 }
 589 
 590 //=============================================================================
 591 #ifndef PRODUCT
 592 void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const {
 593   Compile *C = ra_->C;
 594   int framesize = C->frame_size_in_bytes();
 595   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
 596   // Remove two words for return addr and rbp,
 597   framesize -= 2*wordSize;
 598 
 599   if (C->max_vector_size() > 16) {
 600     st->print("VZEROUPPER");
 601     st->cr(); st->print("\t");
 602   }
 603   if (C->in_24_bit_fp_mode()) {
 604     st->print("FLDCW  standard control word");
 605     st->cr(); st->print("\t");
 606   }
 607   if (framesize) {
 608     st->print("ADD    ESP,%d\t# Destroy frame",framesize);
 609     st->cr(); st->print("\t");
 610   }
 611   st->print_cr("POPL   EBP"); st->print("\t");
 612   if (do_polling() && C->is_method_compilation()) {
 613     st->print("TEST   PollPage,EAX\t! Poll Safepoint");
 614     st->cr(); st->print("\t");
 615   }
 616 }
 617 #endif
 618 
 619 void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
 620   Compile *C = ra_->C;
 621 
 622   if (C->max_vector_size() > 16) {
 623     // Clear upper bits of YMM registers when current compiled code uses
 624     // wide vectors to avoid AVX <-> SSE transition penalty during call.
 625     MacroAssembler masm(&cbuf);
 626     masm.vzeroupper();
 627   }
 628   // If method set FPU control word, restore to standard control word
 629   if (C->in_24_bit_fp_mode()) {
 630     MacroAssembler masm(&cbuf);
 631     masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
 632   }
 633 
 634   int framesize = C->frame_size_in_bytes();
 635   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
 636   // Remove two words for return addr and rbp,
 637   framesize -= 2*wordSize;
 638 
 639   // Note that VerifyStackAtCalls' Majik cookie does not change the frame size popped here
 640 
 641   if (framesize >= 128) {
 642     emit_opcode(cbuf, 0x81); // add  SP, #framesize
 643     emit_rm(cbuf, 0x3, 0x00, ESP_enc);
 644     emit_d32(cbuf, framesize);
 645   } else if (framesize) {
 646     emit_opcode(cbuf, 0x83); // add  SP, #framesize
 647     emit_rm(cbuf, 0x3, 0x00, ESP_enc);
 648     emit_d8(cbuf, framesize);
 649   }
 650 
 651   emit_opcode(cbuf, 0x58 | EBP_enc);
 652 
 653   if (do_polling() && C->is_method_compilation()) {
 654     cbuf.relocate(cbuf.insts_end(), relocInfo::poll_return_type, 0);
 655     emit_opcode(cbuf,0x85);
 656     emit_rm(cbuf, 0x0, EAX_enc, 0x5); // EAX
 657     emit_d32(cbuf, (intptr_t)os::get_polling_page());
 658   }
 659 }
 660 
 661 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const {
 662   Compile *C = ra_->C;
 663   // If method set FPU control word, restore to standard control word
 664   int size = C->in_24_bit_fp_mode() ? 6 : 0;
 665   if (C->max_vector_size() > 16) size += 3; // vzeroupper
 666   if (do_polling() && C->is_method_compilation()) size += 6;
 667 
 668   int framesize = C->frame_size_in_bytes();
 669   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
 670   // Remove two words for return addr and rbp,
 671   framesize -= 2*wordSize;
 672 
 673   size++; // popl rbp,
 674 
 675   if (framesize >= 128) {
 676     size += 6;
 677   } else {
 678     size += framesize ? 3 : 0;
 679   }
 680   return size;
 681 }
 682 
 683 int MachEpilogNode::reloc() const {
 684   return 0; // a large enough number
 685 }
 686 
 687 const Pipeline * MachEpilogNode::pipeline() const {
 688   return MachNode::pipeline_class();


src/cpu/x86/vm/x86_32.ad
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File