comparison graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64GraphBuilderPlugins.java @ 22604:b00cc0475f31

Update jvmci import: Refactoring: Rename Kind to JavaKind.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 08 Sep 2015 19:57:39 +0200
parents e02fa353e88c
children 05183a084a08
comparison
equal deleted inserted replaced
22603:6d339ba0edc5 22604:b00cc0475f31
41 41
42 public class AMD64GraphBuilderPlugins { 42 public class AMD64GraphBuilderPlugins {
43 43
44 public static void register(Plugins plugins, ForeignCallsProvider foreignCalls, AMD64 arch) { 44 public static void register(Plugins plugins, ForeignCallsProvider foreignCalls, AMD64 arch) {
45 InvocationPlugins invocationPlugins = plugins.getInvocationPlugins(); 45 InvocationPlugins invocationPlugins = plugins.getInvocationPlugins();
46 registerIntegerLongPlugins(invocationPlugins, IntegerSubstitutions.class, Kind.Int, arch); 46 registerIntegerLongPlugins(invocationPlugins, IntegerSubstitutions.class, JavaKind.Int, arch);
47 registerIntegerLongPlugins(invocationPlugins, LongSubstitutions.class, Kind.Long, arch); 47 registerIntegerLongPlugins(invocationPlugins, LongSubstitutions.class, JavaKind.Long, arch);
48 registerUnsafePlugins(invocationPlugins); 48 registerUnsafePlugins(invocationPlugins);
49 registerMathPlugins(invocationPlugins, foreignCalls); 49 registerMathPlugins(invocationPlugins, foreignCalls);
50 } 50 }
51 51
52 private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, Kind kind, AMD64 arch) { 52 private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, AMD64 arch) {
53 Class<?> declaringClass = kind.toBoxedJavaClass(); 53 Class<?> declaringClass = kind.toBoxedJavaClass();
54 Class<?> type = kind.toJavaClass(); 54 Class<?> type = kind.toJavaClass();
55 Registration r = new Registration(plugins, declaringClass); 55 Registration r = new Registration(plugins, declaringClass);
56 if (arch.getFlags().contains(AMD64.Flag.UseCountLeadingZerosInstruction)) { 56 if (arch.getFlags().contains(AMD64.Flag.UseCountLeadingZerosInstruction)) {
57 r.register1("numberOfLeadingZeros", type, new InvocationPlugin() { 57 r.register1("numberOfLeadingZeros", type, new InvocationPlugin() {
58 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { 58 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
59 ValueNode folded = AMD64CountLeadingZerosNode.tryFold(value); 59 ValueNode folded = AMD64CountLeadingZerosNode.tryFold(value);
60 if (folded != null) { 60 if (folded != null) {
61 b.addPush(Kind.Int, folded); 61 b.addPush(JavaKind.Int, folded);
62 } else { 62 } else {
63 b.addPush(Kind.Int, new AMD64CountLeadingZerosNode(value)); 63 b.addPush(JavaKind.Int, new AMD64CountLeadingZerosNode(value));
64 } 64 }
65 return true; 65 return true;
66 } 66 }
67 }); 67 });
68 } else { 68 } else {
71 if (arch.getFlags().contains(AMD64.Flag.UseCountTrailingZerosInstruction)) { 71 if (arch.getFlags().contains(AMD64.Flag.UseCountTrailingZerosInstruction)) {
72 r.register1("numberOfTrailingZeros", type, new InvocationPlugin() { 72 r.register1("numberOfTrailingZeros", type, new InvocationPlugin() {
73 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { 73 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
74 ValueNode folded = AMD64CountTrailingZerosNode.tryFold(value); 74 ValueNode folded = AMD64CountTrailingZerosNode.tryFold(value);
75 if (folded != null) { 75 if (folded != null) {
76 b.addPush(Kind.Int, folded); 76 b.addPush(JavaKind.Int, folded);
77 } else { 77 } else {
78 b.addPush(Kind.Int, new AMD64CountTrailingZerosNode(value)); 78 b.addPush(JavaKind.Int, new AMD64CountTrailingZerosNode(value));
79 } 79 }
80 return true; 80 return true;
81 } 81 }
82 }); 82 });
83 } else { 83 } else {
87 87
88 private static void registerMathPlugins(InvocationPlugins plugins, ForeignCallsProvider foreignCalls) { 88 private static void registerMathPlugins(InvocationPlugins plugins, ForeignCallsProvider foreignCalls) {
89 Registration r = new Registration(plugins, Math.class); 89 Registration r = new Registration(plugins, Math.class);
90 r.register1("log", Double.TYPE, new InvocationPlugin() { 90 r.register1("log", Double.TYPE, new InvocationPlugin() {
91 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { 91 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
92 b.push(Kind.Double, b.recursiveAppend(AMD64MathIntrinsicNode.create(value, LOG))); 92 b.push(JavaKind.Double, b.recursiveAppend(AMD64MathIntrinsicNode.create(value, LOG)));
93 return true; 93 return true;
94 } 94 }
95 }); 95 });
96 r.register1("log10", Double.TYPE, new InvocationPlugin() { 96 r.register1("log10", Double.TYPE, new InvocationPlugin() {
97 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { 97 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
98 b.push(Kind.Double, b.recursiveAppend(AMD64MathIntrinsicNode.create(value, LOG10))); 98 b.push(JavaKind.Double, b.recursiveAppend(AMD64MathIntrinsicNode.create(value, LOG10)));
99 return true; 99 return true;
100 } 100 }
101 }); 101 });
102 r.registerMethodSubstitution(AMD64MathSubstitutions.class, "sin", double.class); 102 r.registerMethodSubstitution(AMD64MathSubstitutions.class, "sin", double.class);
103 r.registerMethodSubstitution(AMD64MathSubstitutions.class, "cos", double.class); 103 r.registerMethodSubstitution(AMD64MathSubstitutions.class, "cos", double.class);
107 } 107 }
108 108
109 private static void registerUnsafePlugins(InvocationPlugins plugins) { 109 private static void registerUnsafePlugins(InvocationPlugins plugins) {
110 Registration r = new Registration(plugins, Unsafe.class); 110 Registration r = new Registration(plugins, Unsafe.class);
111 111
112 for (Kind kind : new Kind[]{Kind.Int, Kind.Long, Kind.Object}) { 112 for (JavaKind kind : new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object}) {
113 Class<?> javaClass = kind == Kind.Object ? Object.class : kind.toJavaClass(); 113 Class<?> javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass();
114 114
115 r.register4("getAndSet" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() { 115 r.register4("getAndSet" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() {
116 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode value) { 116 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode value) {
117 // Emits a null-check for the otherwise unused receiver 117 // Emits a null-check for the otherwise unused receiver
118 unsafe.get(); 118 unsafe.get();
119 b.addPush(kind, new AtomicReadAndWriteNode(object, offset, value, kind, LocationIdentity.any())); 119 b.addPush(kind, new AtomicReadAndWriteNode(object, offset, value, kind, LocationIdentity.any()));
120 b.getGraph().markUnsafeAccess(); 120 b.getGraph().markUnsafeAccess();
121 return true; 121 return true;
122 } 122 }
123 }); 123 });
124 if (kind != Kind.Object) { 124 if (kind != JavaKind.Object) {
125 r.register4("getAndAdd" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() { 125 r.register4("getAndAdd" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() {
126 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode delta) { 126 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode delta) {
127 // Emits a null-check for the otherwise unused receiver 127 // Emits a null-check for the otherwise unused receiver
128 unsafe.get(); 128 unsafe.get();
129 AddressNode address = b.add(new OffsetAddressNode(object, offset)); 129 AddressNode address = b.add(new OffsetAddressNode(object, offset));
133 } 133 }
134 }); 134 });
135 } 135 }
136 } 136 }
137 137
138 for (Kind kind : new Kind[]{Kind.Char, Kind.Short, Kind.Int, Kind.Long}) { 138 for (JavaKind kind : new JavaKind[]{JavaKind.Char, JavaKind.Short, JavaKind.Int, JavaKind.Long}) {
139 Class<?> javaClass = kind.toJavaClass(); 139 Class<?> javaClass = kind.toJavaClass();
140 r.registerOptional3("get" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, new UnsafeGetPlugin(kind, false)); 140 r.registerOptional3("get" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, new UnsafeGetPlugin(kind, false));
141 r.registerOptional4("put" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, javaClass, new UnsafePutPlugin(kind, false)); 141 r.registerOptional4("put" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, javaClass, new UnsafePutPlugin(kind, false));
142 } 142 }
143 } 143 }