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
26 package jdk.tools.jaotc;
27
28 import java.util.concurrent.TimeUnit;
29 import java.util.concurrent.atomic.AtomicInteger;
30
31 import org.graalvm.compiler.api.replacements.SnippetReflectionProvider;
32 import org.graalvm.compiler.code.CompilationResult;
33 import org.graalvm.compiler.core.GraalCompilerOptions;
34 import org.graalvm.compiler.debug.DebugContext;
35 import org.graalvm.compiler.debug.TTY;
36 import org.graalvm.compiler.debug.DebugContext.Activation;
37 import org.graalvm.compiler.options.OptionValues;
38 import org.graalvm.compiler.printer.GraalDebugHandlersFactory;
39 import org.graalvm.compiler.serviceprovider.GraalServices;
40
41 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
42 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
43 import jdk.vm.ci.meta.ResolvedJavaMethod;
44 import jdk.vm.ci.runtime.JVMCICompiler;
45
46 /**
47 * Represents a task in the compile queue.
48 *
49 * This class encapsulates all Graal-specific information that is used during offline AOT
50 * compilation of classes. It also defines methods that parse compilation result of Graal to create
51 * target-independent representation {@code BinaryContainer} of the intended target binary.
52 */
53 final class AOTCompilationTask implements Runnable, Comparable<Object> {
54
55 private static final AtomicInteger ids = new AtomicInteger();
56
126 if (printCompilation) {
127 final long stop = System.currentTimeMillis();
128 final int targetCodeSize = compResult != null ? compResult.getTargetCodeSize() : -1;
129 final long allocatedBytesAfter = GraalServices.getThreadAllocatedBytes(threadId);
130 final long allocatedBytes = (allocatedBytesAfter - allocatedBytesBefore) / 1024;
131
132 TTY.println(getMethodDescription() + String.format(" | %4dms %5dB %5dkB", stop - start, targetCodeSize, allocatedBytes));
133 }
134
135 if (compResult == null) {
136 result = null;
137 return;
138 }
139
140 // For now precision to the nearest second is sufficient.
141 LogPrinter.writeLog(" Compile Time: " + TimeUnit.MILLISECONDS.toSeconds(endTime - startTime) + "secs");
142 if (main.options.debug) {
143 aotBackend.printCompiledMethod((HotSpotResolvedJavaMethod) method, compResult);
144 }
145
146 result = new CompiledMethodInfo(compResult, new AOTHotSpotResolvedJavaMethod((HotSpotResolvedJavaMethod) method, aotBackend.getBackend()));
147 }
148
149 private String getMethodDescription() {
150 return String.format("%-6d aot %s %s", getId(), JavaMethodInfo.uniqueMethodName(method),
151 getEntryBCI() == JVMCICompiler.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + getEntryBCI() + ") ");
152 }
153
154 private int getId() {
155 return id;
156 }
157
158 private static int getEntryBCI() {
159 return JVMCICompiler.INVOCATION_ENTRY_BCI;
160 }
161
162 ResolvedJavaMethod getMethod() {
163 return method;
164 }
165
166 /**
|
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
26 package jdk.tools.jaotc;
27
28 import java.util.concurrent.TimeUnit;
29 import java.util.concurrent.atomic.AtomicInteger;
30
31 import org.graalvm.compiler.api.replacements.SnippetReflectionProvider;
32 import org.graalvm.compiler.code.CompilationResult;
33 import org.graalvm.compiler.core.GraalCompilerOptions;
34 import org.graalvm.compiler.debug.DebugContext;
35 import org.graalvm.compiler.debug.DebugContext.Activation;
36 import org.graalvm.compiler.debug.TTY;
37 import org.graalvm.compiler.options.OptionValues;
38 import org.graalvm.compiler.printer.GraalDebugHandlersFactory;
39 import org.graalvm.compiler.serviceprovider.GraalServices;
40
41 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
42 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
43 import jdk.vm.ci.meta.ResolvedJavaMethod;
44 import jdk.vm.ci.runtime.JVMCICompiler;
45
46 /**
47 * Represents a task in the compile queue.
48 *
49 * This class encapsulates all Graal-specific information that is used during offline AOT
50 * compilation of classes. It also defines methods that parse compilation result of Graal to create
51 * target-independent representation {@code BinaryContainer} of the intended target binary.
52 */
53 final class AOTCompilationTask implements Runnable, Comparable<Object> {
54
55 private static final AtomicInteger ids = new AtomicInteger();
56
126 if (printCompilation) {
127 final long stop = System.currentTimeMillis();
128 final int targetCodeSize = compResult != null ? compResult.getTargetCodeSize() : -1;
129 final long allocatedBytesAfter = GraalServices.getThreadAllocatedBytes(threadId);
130 final long allocatedBytes = (allocatedBytesAfter - allocatedBytesBefore) / 1024;
131
132 TTY.println(getMethodDescription() + String.format(" | %4dms %5dB %5dkB", stop - start, targetCodeSize, allocatedBytes));
133 }
134
135 if (compResult == null) {
136 result = null;
137 return;
138 }
139
140 // For now precision to the nearest second is sufficient.
141 LogPrinter.writeLog(" Compile Time: " + TimeUnit.MILLISECONDS.toSeconds(endTime - startTime) + "secs");
142 if (main.options.debug) {
143 aotBackend.printCompiledMethod((HotSpotResolvedJavaMethod) method, compResult);
144 }
145
146 result = new CompiledMethodInfo(compResult, new AOTHotSpotResolvedJavaMethod((HotSpotResolvedJavaMethod) method, aotBackend.getBackend(), graalOptions));
147 }
148
149 private String getMethodDescription() {
150 return String.format("%-6d aot %s %s", getId(), JavaMethodInfo.uniqueMethodName(method),
151 getEntryBCI() == JVMCICompiler.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + getEntryBCI() + ") ");
152 }
153
154 private int getId() {
155 return id;
156 }
157
158 private static int getEntryBCI() {
159 return JVMCICompiler.INVOCATION_ENTRY_BCI;
160 }
161
162 ResolvedJavaMethod getMethod() {
163 return method;
164 }
165
166 /**
|