comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java @ 8251:cb70ed101b5f

Added automatic generation of generic specialization which throws unsupported operation if reached.
author Christian Humer <christian.humer@gmail.com>
date Wed, 13 Mar 2013 11:32:43 +0100
parents c4c3f50fa9c2
children 0905d796944a
comparison
equal deleted inserted replaced
8250:edc414f52e2b 8251:cb70ed101b5f
66 this.specializations = copy.specializations; 66 this.specializations = copy.specializations;
67 this.specializationListeners = copy.specializationListeners; 67 this.specializationListeners = copy.specializationListeners;
68 this.guards = copy.guards; 68 this.guards = copy.guards;
69 this.executableTypes = copy.executableTypes; 69 this.executableTypes = copy.executableTypes;
70 this.shortCircuits = copy.shortCircuits; 70 this.shortCircuits = copy.shortCircuits;
71 71 this.fields = copy.fields;
72 List<NodeFieldData> fieldsCopy = new ArrayList<>();
73 for (NodeFieldData field : copy.fields) {
74 NodeFieldData newField = new NodeFieldData(field);
75 newField.setNode(this);
76 fieldsCopy.add(newField);
77 }
78 this.fields = fieldsCopy;
79 } 72 }
80 73
81 public ParameterSpec getInstanceParameterSpec() { 74 public ParameterSpec getInstanceParameterSpec() {
82 return instanceParameterSpec; 75 return instanceParameterSpec;
83 } 76 }
180 List<ExecutableTypeData> types = findGenericExecutableTypes(context); 173 List<ExecutableTypeData> types = findGenericExecutableTypes(context);
181 for (ExecutableTypeData availableType : types) { 174 for (ExecutableTypeData availableType : types) {
182 if (Utils.typeEquals(availableType.getType().getBoxedType(), type.getBoxedType())) { 175 if (Utils.typeEquals(availableType.getType().getBoxedType(), type.getBoxedType())) {
183 return availableType; 176 return availableType;
184 } 177 }
178 }
179 return null;
180 }
181
182 public ExecutableTypeData findAnyGenericExecutableType(ProcessorContext context) {
183 List<ExecutableTypeData> types = findGenericExecutableTypes(context);
184 if (!types.isEmpty()) {
185 return types.get(0);
185 } 186 }
186 return null; 187 return null;
187 } 188 }
188 189
189 public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) { 190 public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) {
248 return false; 249 return false;
249 } 250 }
250 251
251 public boolean needsRewrites(ProcessorContext context) { 252 public boolean needsRewrites(ProcessorContext context) {
252 boolean needsRewrites = false; 253 boolean needsRewrites = false;
253 for (NodeFieldData field : getFields()) { 254
254 if (field.getExecutionKind() == ExecutionKind.DEFAULT || field.getExecutionKind() == ExecutionKind.SHORT_CIRCUIT) { 255 for (SpecializationData specialization : getSpecializations()) {
255 if (!field.getNodeData().hasUnexpectedExecutableTypes(context)) { 256 if (specialization.hasRewrite(context)) {
256 continue;
257 }
258
259 needsRewrites = true; 257 needsRewrites = true;
260 break; 258 break;
261 } 259 }
262 } 260 }
263
264 needsRewrites &= specializations.size() >= 2;
265 return needsRewrites; 261 return needsRewrites;
266 } 262 }
267 263
268 public SpecializationData getGenericSpecialization() { 264 public SpecializationData getGenericSpecialization() {
269 for (SpecializationData specialization : specializations) { 265 for (SpecializationData specialization : specializations) {