comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java @ 16755:bd28da642eea

Truffle-DSL: Several new features implemented: Implementation of a new code generation layout which shares code between generated nodes. Declaration order of specializations is now used as specialization order. Specializations do no longer perform fallthrough on respecialization, they now always respecialize from the first specialization. Implemented support for contains relations between specializations. Improved reachability error messages. Preliminary support for @Implies.
author Christian Humer <christian.humer@gmail.com>
date Mon, 11 Aug 2014 15:53:05 +0200
parents 64dcb92ee75a
children
comparison
equal deleted inserted replaced
16754:55fd5be68a52 16755:bd28da642eea
52 private final List<CreateCastData> casts = new ArrayList<>(); 52 private final List<CreateCastData> casts = new ArrayList<>();
53 private Map<Integer, List<ExecutableTypeData>> executableTypes; 53 private Map<Integer, List<ExecutableTypeData>> executableTypes;
54 54
55 private final NodeExecutionData thisExecution; 55 private final NodeExecutionData thisExecution;
56 56
57 private int polymorphicDepth = -1; 57 public NodeData(ProcessorContext context, TypeElement type, String shortName, TypeSystemData typeSystem, List<NodeChildData> children, List<NodeExecutionData> executions,
58 58 List<NodeFieldData> fields, List<String> assumptions) {
59 public NodeData(TypeElement type, String shortName, TypeSystemData typeSystem, List<NodeChildData> children, List<NodeExecutionData> executions, List<NodeFieldData> fields, 59 super(context, type, null, null);
60 List<String> assumptions, int polymorphicDepth) {
61 super(type, null, null);
62 this.nodeId = type.getSimpleName().toString(); 60 this.nodeId = type.getSimpleName().toString();
63 this.shortName = shortName; 61 this.shortName = shortName;
64 this.typeSystem = typeSystem; 62 this.typeSystem = typeSystem;
65 this.fields = fields; 63 this.fields = fields;
66 this.children = children; 64 this.children = children;
67 this.childExecutions = executions; 65 this.childExecutions = executions;
68 this.assumptions = assumptions; 66 this.assumptions = assumptions;
69 this.polymorphicDepth = polymorphicDepth;
70 this.thisExecution = new NodeExecutionData(new NodeChildData(null, null, "this", getNodeType(), getNodeType(), null, Cardinality.ONE), -1, false); 67 this.thisExecution = new NodeExecutionData(new NodeChildData(null, null, "this", getNodeType(), getNodeType(), null, Cardinality.ONE), -1, false);
71 this.thisExecution.getChild().setNode(this); 68 this.thisExecution.getChild().setNode(this);
72 if (children != null) { 69 if (children != null) {
73 for (NodeChildData child : children) { 70 for (NodeChildData child : children) {
74 child.setParentNode(this); 71 child.setParentNode(this);
75 } 72 }
76 } 73 }
77 } 74 }
78 75
79 public NodeData(TypeElement type) { 76 public NodeData(ProcessorContext context, TypeElement type) {
80 this(type, null, null, null, null, null, null, -1); 77 this(context, type, null, null, null, null, null, null);
81 } 78 }
82 79
83 public NodeExecutionData getThisExecution() { 80 public NodeExecutionData getThisExecution() {
84 return thisExecution; 81 return thisExecution;
82 }
83
84 public boolean isFallbackReachable() {
85 SpecializationData generic = getGenericSpecialization();
86 if (generic != null) {
87 return generic.isReachable();
88 }
89 return false;
85 } 90 }
86 91
87 public void addEnclosedNode(NodeData node) { 92 public void addEnclosedNode(NodeData node) {
88 this.enclosingNodes.add(node); 93 this.enclosingNodes.add(node);
89 node.declaringNode = this; 94 node.declaringNode = this;
119 } 124 }
120 } 125 }
121 return false; 126 return false;
122 } 127 }
123 128
124 public int getPolymorphicDepth() { 129 public boolean isPolymorphic(ProcessorContext context) {
125 return polymorphicDepth; 130 return needsRewrites(context);
126 }
127
128 public boolean isPolymorphic() {
129 return polymorphicDepth > 1;
130 }
131
132 public void setPolymorphicDepth(int polymorphicDepth) {
133 this.polymorphicDepth = polymorphicDepth;
134 } 131 }
135 132
136 public List<CreateCastData> getCasts() { 133 public List<CreateCastData> getCasts() {
137 return casts; 134 return casts;
138 } 135 }
402 dumpProperty(builder, indent, "templateClass", Utils.getQualifiedName(getTemplateType())); 399 dumpProperty(builder, indent, "templateClass", Utils.getQualifiedName(getTemplateType()));
403 dumpProperty(builder, indent, "typeSystem", getTypeSystem()); 400 dumpProperty(builder, indent, "typeSystem", getTypeSystem());
404 dumpProperty(builder, indent, "fields", getChildren()); 401 dumpProperty(builder, indent, "fields", getChildren());
405 dumpProperty(builder, indent, "executableTypes", getExecutableTypes()); 402 dumpProperty(builder, indent, "executableTypes", getExecutableTypes());
406 dumpProperty(builder, indent, "specializations", getSpecializations()); 403 dumpProperty(builder, indent, "specializations", getSpecializations());
407 dumpProperty(builder, indent, "polymorphicDepth", getPolymorphicDepth());
408 dumpProperty(builder, indent, "assumptions", getAssumptions()); 404 dumpProperty(builder, indent, "assumptions", getAssumptions());
409 dumpProperty(builder, indent, "casts", getCasts()); 405 dumpProperty(builder, indent, "casts", getCasts());
410 dumpProperty(builder, indent, "messages", collectMessages()); 406 dumpProperty(builder, indent, "messages", collectMessages());
411 if (getEnclosingNodes().size() > 0) { 407 if (getEnclosingNodes().size() > 0) {
412 builder.append(String.format("\n%s children = [", indent)); 408 builder.append(String.format("\n%s children = [", indent));