comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/SpecializationData.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 d81ff782fa1a
children 0905d796944a
comparison
equal deleted inserted replaced
8250:edc414f52e2b 8251:cb70ed101b5f
23 package com.oracle.truffle.codegen.processor.node; 23 package com.oracle.truffle.codegen.processor.node;
24 24
25 import java.util.*; 25 import java.util.*;
26 26
27 import com.oracle.truffle.api.codegen.*; 27 import com.oracle.truffle.api.codegen.*;
28 import com.oracle.truffle.codegen.processor.*;
28 import com.oracle.truffle.codegen.processor.template.*; 29 import com.oracle.truffle.codegen.processor.template.*;
29 30
30 public class SpecializationData extends TemplateMethod { 31 public class SpecializationData extends TemplateMethod {
31 32
32 private final int order; 33 private final int order;
36 private SpecializationGuardData[] guards; 37 private SpecializationGuardData[] guards;
37 private ShortCircuitData[] shortCircuits; 38 private ShortCircuitData[] shortCircuits;
38 private boolean useSpecializationsForGeneric = true; 39 private boolean useSpecializationsForGeneric = true;
39 private NodeData node; 40 private NodeData node;
40 41
42 private final boolean synthetic;
43
41 public SpecializationData(TemplateMethod template, int order, List<SpecializationThrowsData> exceptions) { 44 public SpecializationData(TemplateMethod template, int order, List<SpecializationThrowsData> exceptions) {
42 super(template); 45 super(template);
43 this.order = order; 46 this.order = order;
44 this.generic = false; 47 this.generic = false;
45 this.uninitialized = false; 48 this.uninitialized = false;
49 this.synthetic = false;
46 this.exceptions = exceptions; 50 this.exceptions = exceptions;
47 51
48 for (SpecializationThrowsData exception : exceptions) { 52 for (SpecializationThrowsData exception : exceptions) {
49 exception.setSpecialization(this); 53 exception.setSpecialization(this);
50 } 54 }
51 } 55 }
52 56
53 public SpecializationData(TemplateMethod template, boolean generic, boolean uninitialized) { 57 public SpecializationData(TemplateMethod template, boolean generic, boolean uninitialized, boolean synthetic) {
54 super(template); 58 super(template);
55 this.order = Specialization.DEFAULT_ORDER; 59 this.order = Specialization.DEFAULT_ORDER;
56 this.generic = generic; 60 this.generic = generic;
57 this.uninitialized = uninitialized; 61 this.uninitialized = uninitialized;
58 this.exceptions = Collections.emptyList(); 62 this.exceptions = Collections.emptyList();
59 this.guards = new SpecializationGuardData[0]; 63 this.guards = new SpecializationGuardData[0];
64 this.synthetic = synthetic;
65 }
66
67 public boolean hasRewrite(ProcessorContext context) {
68 if (getExceptions().size() > 0) {
69 return true;
70 }
71 if (getGuards().length > 0) {
72 return true;
73 }
74 for (ActualParameter parameter : getParameters()) {
75 NodeFieldData field = getNode().findField(parameter.getSpecification().getName());
76 if (field == null) {
77 continue;
78 }
79 ExecutableTypeData type = field.getNodeData().findExecutableType(parameter.getActualTypeData(field.getNodeData().getTypeSystem()));
80 if (type.hasUnexpectedValue(context)) {
81 return true;
82 }
83 }
84 return false;
60 } 85 }
61 86
62 public NodeData getNode() { 87 public NodeData getNode() {
63 return node; 88 return node;
64 } 89 }
67 this.node = node; 92 this.node = node;
68 } 93 }
69 94
70 public void setGuards(SpecializationGuardData[] guards) { 95 public void setGuards(SpecializationGuardData[] guards) {
71 this.guards = guards; 96 this.guards = guards;
97 }
98
99 public boolean isSynthetic() {
100 return synthetic;
72 } 101 }
73 102
74 public int getOrder() { 103 public int getOrder() {
75 return order; 104 return order;
76 } 105 }