Skip to content

Commit

Permalink
[GR-47019] Make Image Heap code more extensible
Browse files Browse the repository at this point in the history
PullRequest: graal/18427
  • Loading branch information
patrick96 committed Aug 14, 2024
2 parents fd731c3 + b95de21 commit 5455e10
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
package jdk.graal.compiler.hightiercodegen;

import jdk.graal.compiler.debug.GraalError;
import jdk.graal.compiler.graph.GraalGraphError;
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.graph.iterators.NodeIterable;
import jdk.graal.compiler.hightiercodegen.variables.ResolvedVar;
Expand Down Expand Up @@ -351,7 +351,7 @@ protected void dispatch(Node node) {
* ignored.
*/
protected void handleUnknownNodeType(Node node) {
throw GraalError.unimplemented("Could not lower node: " + node);
throw new GraalGraphError("No lowerings found for node: %s", node).addContext(node);
}

protected abstract void lower(BlackholeNode node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import jdk.graal.compiler.core.common.cfg.BlockMap;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.DebugContext.Scope;
import jdk.graal.compiler.debug.GraalError;
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.graph.NodeMap;
import jdk.graal.compiler.hightiercodegen.CodeGenTool;
Expand Down Expand Up @@ -73,7 +74,7 @@ public void lowerFunction(DebugContext debugContext) {
lower(debugContext);
verifier.verify(cfg.graph, codeGenTool, reconstructionData);
} catch (Throwable t) {
throw debugContext.handle(t);
throw debugContext.handle(new GraalError(t).addContext("graph", cfg.graph));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
import java.util.Set;
import java.util.stream.Collectors;

import com.oracle.svm.core.meta.CompressedNullConstant;
import com.oracle.svm.core.interpreter.InterpreterSupport;
import org.graalvm.collections.Pair;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.Platform;
Expand Down Expand Up @@ -83,6 +81,8 @@
import com.oracle.svm.core.configure.ConditionalRuntimeValue;
import com.oracle.svm.core.deopt.DeoptEntryInfopoint;
import com.oracle.svm.core.graal.code.SubstrateDataBuilder;
import com.oracle.svm.core.interpreter.InterpreterSupport;
import com.oracle.svm.core.meta.CompressedNullConstant;
import com.oracle.svm.core.meta.MethodPointer;
import com.oracle.svm.core.meta.SubstrateMethodPointerConstant;
import com.oracle.svm.core.option.HostedOptionKey;
Expand Down Expand Up @@ -269,9 +269,13 @@ public Map<Constant, Object> initAndGetEmbeddedConstants() {
return embeddedConstants;
}

public void addConstantsToHeap() {
public Map<Constant, Object> getEmbeddedConstants() {
VMError.guarantee(!embeddedConstants.isEmpty(), "Embedded constants should already be computed.");
embeddedConstants.forEach((constant, reason) -> addConstantToHeap(constant, reason instanceof BytecodePosition position ? position.getMethod().getName() : reason));
return Collections.unmodifiableMap(embeddedConstants);
}

public void addConstantsToHeap() {
getEmbeddedConstants().forEach((constant, reason) -> addConstantToHeap(constant, reason instanceof BytecodePosition position ? position.getMethod().getName() : reason));
}

private void addConstantToHeap(Constant constant, Object reason) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ private static HostedType requireType(Optional<HostedType> optionalType, Object
return hostedType;
}

static RuntimeException reportIllegalType(Object object, Object reason) {
public static RuntimeException reportIllegalType(Object object, Object reason) {
throw reportIllegalType(object, reason, "");
}

Expand Down

0 comments on commit 5455e10

Please sign in to comment.