1 /*
2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
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
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 
25 package org.graalvm.compiler.hotspot;
26 
27 import jdk.internal.vm.compiler.collections.EconomicMap;
28 import jdk.internal.vm.compiler.collections.Equivalence;
29 import org.graalvm.compiler.core.common.CompilationIdentifier;
30 import org.graalvm.compiler.hotspot.stubs.Stub;
31 import org.graalvm.compiler.lir.LIR;
32 import org.graalvm.compiler.lir.LIRFrameState;
33 import org.graalvm.compiler.lir.StandardOp.SaveRegistersOp;
34 import org.graalvm.compiler.lir.framemap.FrameMapBuilder;
35 import org.graalvm.compiler.lir.gen.LIRGenerationResult;
36 
37 import jdk.vm.ci.code.CallingConvention;
38 import jdk.vm.ci.code.StackSlot;
39 
40 public class HotSpotLIRGenerationResult extends LIRGenerationResult {
41 
42     /**
43      * The slot reserved for storing the original return address when a frame is marked for
44      * deoptimization. The return address slot in the callee is overwritten with the address of a
45      * deoptimization stub.
46      */
47     private StackSlot deoptimizationRescueSlot;
48     protected final Object stub;
49     private final boolean requiresReservedStackAccessCheck;
50 
51     private int maxInterpreterFrameSize;
52 
53     /**
54      * Map from debug infos that need to be updated with callee save information to the operations
55      * that provide the information.
56      */
57     private EconomicMap<LIRFrameState, SaveRegistersOp> calleeSaveInfo = EconomicMap.create(Equivalence.IDENTITY_WITH_SYSTEM_HASHCODE);
58 
HotSpotLIRGenerationResult(CompilationIdentifier compilationId, LIR lir, FrameMapBuilder frameMapBuilder, CallingConvention callingConvention, Object stub, boolean requiresReservedStackAccessCheck)59     public HotSpotLIRGenerationResult(CompilationIdentifier compilationId, LIR lir, FrameMapBuilder frameMapBuilder, CallingConvention callingConvention, Object stub,
60                     boolean requiresReservedStackAccessCheck) {
61         super(compilationId, lir, frameMapBuilder, callingConvention);
62         this.stub = stub;
63         this.requiresReservedStackAccessCheck = requiresReservedStackAccessCheck;
64     }
65 
getCalleeSaveInfo()66     public EconomicMap<LIRFrameState, SaveRegistersOp> getCalleeSaveInfo() {
67         return calleeSaveInfo;
68     }
69 
getStub()70     public Stub getStub() {
71         return (Stub) stub;
72     }
73 
getDeoptimizationRescueSlot()74     public StackSlot getDeoptimizationRescueSlot() {
75         return deoptimizationRescueSlot;
76     }
77 
setDeoptimizationRescueSlot(StackSlot stackSlot)78     public final void setDeoptimizationRescueSlot(StackSlot stackSlot) {
79         this.deoptimizationRescueSlot = stackSlot;
80     }
81 
setMaxInterpreterFrameSize(int maxInterpreterFrameSize)82     public void setMaxInterpreterFrameSize(int maxInterpreterFrameSize) {
83         this.maxInterpreterFrameSize = maxInterpreterFrameSize;
84     }
85 
getMaxInterpreterFrameSize()86     public int getMaxInterpreterFrameSize() {
87         return maxInterpreterFrameSize;
88     }
89 
requiresReservedStackAccessCheck()90     public boolean requiresReservedStackAccessCheck() {
91         return requiresReservedStackAccessCheck;
92     }
93 }
94