|
1 | 1 | /* |
2 | | - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
24 | 24 | */ |
25 | 25 | package jdk.graal.compiler.libgraal; |
26 | 26 |
|
| 27 | +import static jdk.graal.compiler.serviceprovider.GraalServices.getCurrentThreadAllocatedBytes; |
| 28 | +import static jdk.graal.compiler.serviceprovider.GraalServices.isThreadAllocatedMemorySupported; |
| 29 | + |
27 | 30 | import java.io.ByteArrayOutputStream; |
28 | 31 | import java.io.PrintStream; |
29 | 32 | import java.util.Arrays; |
30 | 33 | import java.util.Map; |
31 | 34 |
|
| 35 | +import org.graalvm.collections.EconomicMap; |
| 36 | +import org.graalvm.jniutils.JNI.JNIEnv; |
| 37 | +import org.graalvm.jniutils.JNIExceptionWrapper; |
| 38 | +import org.graalvm.jniutils.JNIMethodScope; |
| 39 | +import org.graalvm.nativeimage.Platform; |
| 40 | +import org.graalvm.nativeimage.Platforms; |
| 41 | +import org.graalvm.nativeimage.c.function.CEntryPoint; |
| 42 | +import org.graalvm.nativeimage.c.function.CEntryPoint.IsolateThreadContext; |
| 43 | +import org.graalvm.nativeimage.c.type.CTypeConversion; |
| 44 | +import org.graalvm.word.PointerBase; |
| 45 | + |
32 | 46 | import jdk.graal.compiler.debug.GlobalMetrics; |
| 47 | +import jdk.graal.compiler.debug.GraalError; |
33 | 48 | import jdk.graal.compiler.hotspot.CompilationContext; |
34 | 49 | import jdk.graal.compiler.hotspot.CompilationTask; |
35 | 50 | import jdk.graal.compiler.hotspot.HotSpotGraalCompiler; |
|
42 | 57 | import jdk.graal.compiler.options.OptionsParser; |
43 | 58 | import jdk.graal.compiler.util.OptionsEncoder; |
44 | 59 | import jdk.graal.compiler.word.Word; |
| 60 | +import jdk.internal.misc.Unsafe; |
45 | 61 | import jdk.vm.ci.hotspot.HotSpotCompilationRequest; |
| 62 | +import jdk.vm.ci.hotspot.HotSpotCompilationRequestResult; |
46 | 63 | import jdk.vm.ci.hotspot.HotSpotInstalledCode; |
47 | 64 | import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; |
48 | 65 | import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; |
|
53 | 70 | import jdk.vm.ci.meta.ResolvedJavaField; |
54 | 71 | import jdk.vm.ci.runtime.JVMCIBackend; |
55 | 72 | import jdk.vm.ci.runtime.JVMCICompiler; |
56 | | -import org.graalvm.collections.EconomicMap; |
57 | | -import org.graalvm.jniutils.JNI.JNIEnv; |
58 | | -import org.graalvm.jniutils.JNIExceptionWrapper; |
59 | | -import org.graalvm.jniutils.JNIMethodScope; |
60 | | -import org.graalvm.nativeimage.Platform; |
61 | | -import org.graalvm.nativeimage.Platforms; |
62 | | -import org.graalvm.nativeimage.c.function.CEntryPoint; |
63 | | -import org.graalvm.nativeimage.c.function.CEntryPoint.IsolateThreadContext; |
64 | | -import org.graalvm.nativeimage.c.type.CTypeConversion; |
65 | | -import org.graalvm.word.PointerBase; |
66 | | - |
67 | | -import jdk.internal.misc.Unsafe; |
68 | | - |
69 | | -import static jdk.graal.compiler.serviceprovider.GraalServices.getCurrentThreadAllocatedBytes; |
70 | | -import static jdk.graal.compiler.serviceprovider.GraalServices.isThreadAllocatedMemorySupported; |
71 | 73 |
|
72 | 74 | /** |
73 | 75 | * Encapsulates {@link CEntryPoint} implementations. |
@@ -185,7 +187,10 @@ private static long compileMethod(JNIEnv jniEnv, |
185 | 187 | String profileLoadPath = CTypeConversion.toJavaString(Word.pointer(profilePathBufferAddress)); |
186 | 188 | options = new OptionValues(options, ProfileReplaySupport.Options.LoadProfiles, profileLoadPath); |
187 | 189 | } |
188 | | - task.runCompilation(options); |
| 190 | + HotSpotCompilationRequestResult compilationRequestResult = task.runCompilation(options); |
| 191 | + if (compilationRequestResult.getFailure() != null) { |
| 192 | + throw new GraalError(compilationRequestResult.getFailureMessage()); |
| 193 | + } |
189 | 194 | if (timeAndMemBufferAddress != 0) { |
190 | 195 | long allocatedBytesAfter = allocatedBytesBefore == -1 ? -1 : getCurrentThreadAllocatedBytes(); |
191 | 196 | long bytesAllocated = allocatedBytesAfter - allocatedBytesBefore; |
|
0 commit comments