1 /*
2  * Copyright (c) 2015, 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 package jdk.vm.ci.hotspot;
24 
25 import jdk.vm.ci.code.CompilationRequest;
26 import jdk.vm.ci.code.CompilationRequestResult;
27 
28 /**
29  * HotSpot specific information about the result of a {@link CompilationRequest}.
30  */
31 public final class HotSpotCompilationRequestResult implements CompilationRequestResult {
32 
33     /**
34      * A user readable description of the failure.
35      *
36      * This field is read by the VM.
37      */
38     private final String failureMessage;
39 
40     /**
41      * Whether this is a transient failure where retrying would help.
42      *
43      * This field is read by the VM.
44      */
45     private final boolean retry;
46 
47     /**
48      * Number of bytecodes inlined into the compilation, exclusive of the bytecodes in the root
49      * method.
50      *
51      * This field is read by the VM.
52      */
53     private final int inlinedBytecodes;
54 
HotSpotCompilationRequestResult(String failureMessage, boolean retry, int inlinedBytecodes)55     private HotSpotCompilationRequestResult(String failureMessage, boolean retry, int inlinedBytecodes) {
56         this.failureMessage = failureMessage;
57         this.retry = retry;
58         this.inlinedBytecodes = inlinedBytecodes;
59     }
60 
61     @Override
getFailure()62     public Object getFailure() {
63         return failureMessage;
64     }
65 
66     /**
67      * Creates a result representing a successful compilation.
68      *
69      * @param inlinedBytecodes number of bytecodes inlined into the compilation, exclusive of the
70      *            bytecodes in the root method
71      */
success(int inlinedBytecodes)72     public static HotSpotCompilationRequestResult success(int inlinedBytecodes) {
73         return new HotSpotCompilationRequestResult(null, true, inlinedBytecodes);
74     }
75 
76     /**
77      * Creates a result representing a failed compilation.
78      *
79      * @param failureMessage a description of the failure
80      * @param retry whether this is a transient failure where retrying may succeed
81      */
failure(String failureMessage, boolean retry)82     public static HotSpotCompilationRequestResult failure(String failureMessage, boolean retry) {
83         return new HotSpotCompilationRequestResult(failureMessage, retry, 0);
84     }
85 
getFailureMessage()86     public String getFailureMessage() {
87         return failureMessage;
88     }
89 
getRetry()90     public boolean getRetry() {
91         return retry;
92     }
93 
getInlinedBytecodes()94     public int getInlinedBytecodes() {
95         return inlinedBytecodes;
96     }
97 }
98