46 * {@link ConstantNode} is created if it isn't already a {@link ConstantNode}).
47 */
48 public ConstantBindingParameterPlugin(Object[] constantArgs, MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection) {
49 this.constantArgs = constantArgs;
50 this.metaAccess = metaAccess;
51 this.snippetReflection = snippetReflection;
52 }
53
54 @Override
55 public FloatingNode interceptParameter(GraphBuilderTool b, int index, StampPair stamp) {
56 Object arg = constantArgs[index];
57 if (arg != null) {
58 ConstantNode constantNode;
59 if (arg instanceof ConstantNode) {
60 ConstantNode otherCon = (ConstantNode) arg;
61 if (otherCon.graph() != b.getGraph()) {
62 /*
63 * This is a node from another graph, so copy over extra state into a new
64 * ConstantNode.
65 */
66 constantNode = ConstantNode.forConstant(stamp.getTrustedStamp(), otherCon.asConstant(), otherCon.getStableDimension(), otherCon.isDefaultStable(), metaAccess);
67 } else {
68 constantNode = otherCon;
69 }
70 } else if (arg instanceof Constant) {
71 constantNode = ConstantNode.forConstant(stamp.getTrustedStamp(), (Constant) arg, metaAccess);
72 } else {
73 constantNode = ConstantNode.forConstant(snippetReflection.forBoxed(stamp.getTrustedStamp().getStackKind(), arg), metaAccess);
74 }
75 return constantNode;
76 }
77 return null;
78 }
79 }
|
46 * {@link ConstantNode} is created if it isn't already a {@link ConstantNode}).
47 */
48 public ConstantBindingParameterPlugin(Object[] constantArgs, MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection) {
49 this.constantArgs = constantArgs;
50 this.metaAccess = metaAccess;
51 this.snippetReflection = snippetReflection;
52 }
53
54 @Override
55 public FloatingNode interceptParameter(GraphBuilderTool b, int index, StampPair stamp) {
56 Object arg = constantArgs[index];
57 if (arg != null) {
58 ConstantNode constantNode;
59 if (arg instanceof ConstantNode) {
60 ConstantNode otherCon = (ConstantNode) arg;
61 if (otherCon.graph() != b.getGraph()) {
62 /*
63 * This is a node from another graph, so copy over extra state into a new
64 * ConstantNode.
65 */
66 constantNode = ConstantNode.forConstant(stamp.getTrustedStamp(), otherCon.getValue(), otherCon.getStableDimension(), otherCon.isDefaultStable(), metaAccess);
67 } else {
68 constantNode = otherCon;
69 }
70 } else if (arg instanceof Constant) {
71 constantNode = ConstantNode.forConstant(stamp.getTrustedStamp(), (Constant) arg, metaAccess);
72 } else {
73 constantNode = ConstantNode.forConstant(snippetReflection.forBoxed(stamp.getTrustedStamp().getStackKind(), arg), metaAccess);
74 }
75 return constantNode;
76 }
77 return null;
78 }
79 }
|