Mercurial > hg > truffle
comparison graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java @ 21391:8cc395785d0a
Expand functionality of FieldIntrospection
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 14 May 2015 16:17:36 -0700 |
parents | 7b8843cc6610 |
children | 5e868236654f |
comparison
equal
deleted
inserted
replaced
21390:f9024b74dd9e | 21391:8cc395785d0a |
---|---|
239 } | 239 } |
240 } | 240 } |
241 return shortName; | 241 return shortName; |
242 } | 242 } |
243 | 243 |
244 @Override | |
245 public Fields[] getAllFields() { | |
246 return new Fields[]{data, inputs, successors}; | |
247 } | |
248 | |
244 public int[] iterableIds() { | 249 public int[] iterableIds() { |
245 nodeIterableCount.increment(); | 250 nodeIterableCount.increment(); |
246 return iterableIds; | 251 return iterableIds; |
247 } | 252 } |
248 | 253 |
286 /** | 291 /** |
287 * Describes a field representing an input or successor edge in a node. | 292 * Describes a field representing an input or successor edge in a node. |
288 */ | 293 */ |
289 protected static class EdgeInfo extends FieldsScanner.FieldInfo { | 294 protected static class EdgeInfo extends FieldsScanner.FieldInfo { |
290 | 295 |
291 public EdgeInfo(long offset, String name, Class<?> type) { | 296 public EdgeInfo(long offset, String name, Class<?> type, Class<?> declaringClass) { |
292 super(offset, name, type); | 297 super(offset, name, type, declaringClass); |
293 } | 298 } |
294 | 299 |
295 /** | 300 /** |
296 * Sorts non-list edges before list edges. | 301 * Sorts non-list edges before list edges. |
297 */ | 302 */ |
315 */ | 320 */ |
316 protected static class InputInfo extends EdgeInfo { | 321 protected static class InputInfo extends EdgeInfo { |
317 final InputType inputType; | 322 final InputType inputType; |
318 final boolean optional; | 323 final boolean optional; |
319 | 324 |
320 public InputInfo(long offset, String name, Class<?> type, InputType inputType, boolean optional) { | 325 public InputInfo(long offset, String name, Class<?> type, Class<?> declaringClass, InputType inputType, boolean optional) { |
321 super(offset, name, type); | 326 super(offset, name, type, declaringClass); |
322 this.inputType = inputType; | 327 this.inputType = inputType; |
323 this.optional = optional; | 328 this.optional = optional; |
324 } | 329 } |
325 | 330 |
326 @Override | 331 @Override |
373 assert optionalInputAnnotation == null : "inputs can either be optional or non-optional"; | 378 assert optionalInputAnnotation == null : "inputs can either be optional or non-optional"; |
374 inputType = inputAnnotation.value(); | 379 inputType = inputAnnotation.value(); |
375 } else { | 380 } else { |
376 inputType = optionalInputAnnotation.value(); | 381 inputType = optionalInputAnnotation.value(); |
377 } | 382 } |
378 inputs.add(new InputInfo(offset, field.getName(), type, inputType, field.isAnnotationPresent(Node.OptionalInput.class))); | 383 inputs.add(new InputInfo(offset, field.getName(), type, field.getDeclaringClass(), inputType, field.isAnnotationPresent(Node.OptionalInput.class))); |
379 } else if (successorAnnotation != null) { | 384 } else if (successorAnnotation != null) { |
380 if (SUCCESSOR_LIST_CLASS.isAssignableFrom(type)) { | 385 if (SUCCESSOR_LIST_CLASS.isAssignableFrom(type)) { |
381 // NodeSuccessorList fields should not be final since they are | 386 // NodeSuccessorList fields should not be final since they are |
382 // written (via Unsafe) in clearSuccessors() | 387 // written (via Unsafe) in clearSuccessors() |
383 GraalInternalError.guarantee(!Modifier.isFinal(modifiers), "NodeSuccessorList successor field % should not be final", field); | 388 GraalInternalError.guarantee(!Modifier.isFinal(modifiers), "NodeSuccessorList successor field % should not be final", field); |
385 } else { | 390 } else { |
386 GraalInternalError.guarantee(NODE_CLASS.isAssignableFrom(type), "invalid successor type: %s", type); | 391 GraalInternalError.guarantee(NODE_CLASS.isAssignableFrom(type), "invalid successor type: %s", type); |
387 GraalInternalError.guarantee(!Modifier.isFinal(modifiers), "Node successor field %s should not be final", field); | 392 GraalInternalError.guarantee(!Modifier.isFinal(modifiers), "Node successor field %s should not be final", field); |
388 directSuccessors++; | 393 directSuccessors++; |
389 } | 394 } |
390 successors.add(new EdgeInfo(offset, field.getName(), type)); | 395 successors.add(new EdgeInfo(offset, field.getName(), type, field.getDeclaringClass())); |
391 } else { | 396 } else { |
392 GraalInternalError.guarantee(!NODE_CLASS.isAssignableFrom(type) || field.getName().equals("Null"), "suspicious node field: %s", field); | 397 GraalInternalError.guarantee(!NODE_CLASS.isAssignableFrom(type) || field.getName().equals("Null"), "suspicious node field: %s", field); |
393 GraalInternalError.guarantee(!INPUT_LIST_CLASS.isAssignableFrom(type), "suspicious node input list field: %s", field); | 398 GraalInternalError.guarantee(!INPUT_LIST_CLASS.isAssignableFrom(type), "suspicious node input list field: %s", field); |
394 GraalInternalError.guarantee(!SUCCESSOR_LIST_CLASS.isAssignableFrom(type), "suspicious node successor list field: %s", field); | 399 GraalInternalError.guarantee(!SUCCESSOR_LIST_CLASS.isAssignableFrom(type), "suspicious node successor list field: %s", field); |
395 super.scanField(field, offset); | 400 super.scanField(field, offset); |