comparison graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/UnsupportedSpecializationException.java @ 21878:79fb8b5ef185

Truffle-DSL: compute UnsupportedSpecializationException message lazily; Add a @TruffleBoundary to its constructor as it may end up on the fast path.
author Christian Humer <christian.humer@gmail.com>
date Tue, 09 Jun 2015 12:50:43 +0200
parents 28479abd1a69
children
comparison
equal deleted inserted replaced
21877:23f0f181bc05 21878:79fb8b5ef185
24 */ 24 */
25 package com.oracle.truffle.api.dsl; 25 package com.oracle.truffle.api.dsl;
26 26
27 import java.util.*; 27 import java.util.*;
28 28
29 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
29 import com.oracle.truffle.api.nodes.*; 30 import com.oracle.truffle.api.nodes.*;
30 31
31 /** 32 /**
32 * Thrown by the generated code of Truffle-DSL if no compatible Specialization could be found for 33 * Thrown by the generated code of Truffle-DSL if no compatible Specialization could be found for
33 * the provided values. 34 * the provided values.
38 39
39 private final Node node; 40 private final Node node;
40 private final Node[] suppliedNodes; 41 private final Node[] suppliedNodes;
41 private final Object[] suppliedValues; 42 private final Object[] suppliedValues;
42 43
44 @TruffleBoundary
43 public UnsupportedSpecializationException(Node node, Node[] suppliedNodes, Object... suppliedValues) { 45 public UnsupportedSpecializationException(Node node, Node[] suppliedNodes, Object... suppliedValues) {
44 super("Unexpected values provided for " + node + ": " + Arrays.toString(suppliedValues));
45 Objects.requireNonNull(suppliedNodes, "The suppliedNodes parameter must not be null."); 46 Objects.requireNonNull(suppliedNodes, "The suppliedNodes parameter must not be null.");
46 if (suppliedNodes.length != suppliedValues.length) { 47 if (suppliedNodes.length != suppliedValues.length) {
47 throw new IllegalArgumentException("The length of suppliedNodes must match the length of suppliedValues."); 48 throw new IllegalArgumentException("The length of suppliedNodes must match the length of suppliedValues.");
48 } 49 }
49 this.node = node; 50 this.node = node;
50 this.suppliedNodes = suppliedNodes; 51 this.suppliedNodes = suppliedNodes;
51 this.suppliedValues = suppliedValues; 52 this.suppliedValues = suppliedValues;
53 }
54
55 @Override
56 public String getMessage() {
57 return String.format("Unexpected values provided for %s: %s", node, Arrays.toString(suppliedValues));
52 } 58 }
53 59
54 /** 60 /**
55 * Returns the {@link Node} that caused the this {@link UnsupportedSpecializationException}. 61 * Returns the {@link Node} that caused the this {@link UnsupportedSpecializationException}.
56 */ 62 */