src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java
changeset 59095 03fbcd06b4c0
parent 58299 6df94ce3ab2f
equal deleted inserted replaced
59094:5d4c3724e4c7 59095:03fbcd06b4c0
   151         final StackSlot reservedSlot;
   151         final StackSlot reservedSlot;
   152 
   152 
   153         SaveRbp(NoOp placeholder) {
   153         SaveRbp(NoOp placeholder) {
   154             this.placeholder = placeholder;
   154             this.placeholder = placeholder;
   155             AMD64FrameMapBuilder frameMapBuilder = (AMD64FrameMapBuilder) getResult().getFrameMapBuilder();
   155             AMD64FrameMapBuilder frameMapBuilder = (AMD64FrameMapBuilder) getResult().getFrameMapBuilder();
   156             this.reservedSlot = frameMapBuilder.allocateRBPSpillSlot();
   156             this.reservedSlot = config.preserveFramePointer ? null : frameMapBuilder.allocateRBPSpillSlot();
   157         }
   157         }
   158 
   158 
   159         /**
   159         /**
   160          * Replaces this operation with the appropriate move for saving rbp.
   160          * Replaces this operation with the appropriate move for saving rbp.
   161          *
   161          *
   162          * @param useStack specifies if rbp must be saved to the stack
   162          * @param useStack specifies if rbp must be saved to the stack
   163          */
   163          */
   164         public AllocatableValue finalize(boolean useStack) {
   164         public AllocatableValue finalize(boolean useStack) {
       
   165             assert !config.preserveFramePointer : "rbp has been pushed onto the stack";
   165             AllocatableValue dst;
   166             AllocatableValue dst;
   166             if (useStack) {
   167             if (useStack) {
   167                 dst = reservedSlot;
   168                 dst = reservedSlot;
   168             } else {
   169             } else {
   169                 ((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).freeRBPSpillSlot();
   170                 ((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).freeRBPSpillSlot();
   171             }
   172             }
   172 
   173 
   173             placeholder.replace(getResult().getLIR(), new MoveFromRegOp(AMD64Kind.QWORD, dst, rbp.asValue(LIRKind.value(AMD64Kind.QWORD))));
   174             placeholder.replace(getResult().getLIR(), new MoveFromRegOp(AMD64Kind.QWORD, dst, rbp.asValue(LIRKind.value(AMD64Kind.QWORD))));
   174             return dst;
   175             return dst;
   175         }
   176         }
       
   177 
       
   178         public void remove() {
       
   179             placeholder.remove(getResult().getLIR());
       
   180         }
   176     }
   181     }
   177 
   182 
   178     private SaveRbp saveRbp;
   183     private SaveRbp saveRbp;
   179 
   184 
   180     protected void emitSaveRbp() {
   185     protected void emitSaveRbp() {
   181         NoOp placeholder = new NoOp(getCurrentBlock(), getResult().getLIR().getLIRforBlock(getCurrentBlock()).size());
   186         NoOp placeholder = new NoOp(getCurrentBlock(), getResult().getLIR().getLIRforBlock(getCurrentBlock()).size());
   182         append(placeholder);
   187         append(placeholder);
   183         saveRbp = new SaveRbp(placeholder);
   188         saveRbp = new SaveRbp(placeholder);
   184     }
       
   185 
       
   186     protected SaveRbp getSaveRbp() {
       
   187         return saveRbp;
       
   188     }
   189     }
   189 
   190 
   190     /**
   191     /**
   191      * Helper instruction to reserve a stack slot for the whole method. Note that the actual users
   192      * Helper instruction to reserve a stack slot for the whole method. Note that the actual users
   192      * of the stack slot might be inserted after stack slot allocation. This dummy instruction
   193      * of the stack slot might be inserted after stack slot allocation. This dummy instruction
   545 
   546 
   546     @Override
   547     @Override
   547     public void beforeRegisterAllocation() {
   548     public void beforeRegisterAllocation() {
   548         super.beforeRegisterAllocation();
   549         super.beforeRegisterAllocation();
   549         boolean hasDebugInfo = getResult().getLIR().hasDebugInfo();
   550         boolean hasDebugInfo = getResult().getLIR().hasDebugInfo();
   550         AllocatableValue savedRbp = saveRbp.finalize(hasDebugInfo);
   551 
       
   552         if (config.preserveFramePointer) {
       
   553             saveRbp.remove();
       
   554         } else {
       
   555             AllocatableValue savedRbp = saveRbp.finalize(hasDebugInfo);
       
   556             for (AMD64HotSpotRestoreRbpOp op : epilogueOps) {
       
   557                 op.setSavedRbp(savedRbp);
       
   558             }
       
   559         }
       
   560 
   551         if (hasDebugInfo) {
   561         if (hasDebugInfo) {
   552             getResult().setDeoptimizationRescueSlot(((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).allocateDeoptimizationRescueSlot());
   562             getResult().setDeoptimizationRescueSlot(((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).allocateDeoptimizationRescueSlot());
   553         }
   563         }
   554 
       
   555         getResult().setMaxInterpreterFrameSize(debugInfoBuilder.maxInterpreterFrameSize());
   564         getResult().setMaxInterpreterFrameSize(debugInfoBuilder.maxInterpreterFrameSize());
   556 
   565 
   557         for (AMD64HotSpotRestoreRbpOp op : epilogueOps) {
       
   558             op.setSavedRbp(savedRbp);
       
   559         }
       
   560         if (BenchmarkCounters.enabled) {
   566         if (BenchmarkCounters.enabled) {
   561             // ensure that the rescue slot is available
   567             // ensure that the rescue slot is available
   562             LIRInstruction op = getOrInitRescueSlotOp();
   568             LIRInstruction op = getOrInitRescueSlotOp();
   563             // insert dummy instruction into the start block
   569             // insert dummy instruction into the start block
   564             LIR lir = getResult().getLIR();
   570             LIR lir = getResult().getLIR();