|
25 | 25 | */
|
26 | 26 | package java.lang.foreign;
|
27 | 27 |
|
28 |
| -import java.lang.constant.ClassDesc; |
29 |
| -import java.lang.constant.ConstantDesc; |
30 |
| -import java.lang.constant.DirectMethodHandleDesc; |
31 |
| -import java.lang.constant.DynamicConstantDesc; |
32 |
| -import java.lang.constant.MethodHandleDesc; |
33 |
| -import java.lang.constant.MethodTypeDesc; |
34 |
| -import java.nio.ByteOrder; |
35 | 28 | import java.util.Objects;
|
36 | 29 | import java.util.Optional;
|
37 | 30 | import jdk.internal.foreign.Utils;
|
38 | 31 | import jdk.internal.vm.annotation.Stable;
|
39 | 32 |
|
40 |
| -import static java.lang.constant.ConstantDescs.BSM_GET_STATIC_FINAL; |
41 |
| -import static java.lang.constant.ConstantDescs.BSM_INVOKE; |
42 |
| -import static java.lang.constant.ConstantDescs.CD_Class; |
43 |
| -import static java.lang.constant.ConstantDescs.CD_String; |
44 |
| -import static java.lang.constant.ConstantDescs.CD_long; |
45 |
| - |
46 | 33 | abstract non-sealed class AbstractLayout implements MemoryLayout {
|
47 | 34 |
|
48 | 35 | private final long size;
|
@@ -122,19 +109,6 @@ String decorateLayoutString(String s) {
|
122 | 109 | return s;
|
123 | 110 | }
|
124 | 111 |
|
125 |
| - <T> DynamicConstantDesc<T> decorateLayoutConstant(DynamicConstantDesc<T> desc) { |
126 |
| - if (!hasNaturalAlignment()) { |
127 |
| - desc = DynamicConstantDesc.ofNamed(BSM_INVOKE, "withBitAlignment", desc.constantType(), MH_WITH_BIT_ALIGNMENT, |
128 |
| - desc, bitAlignment()); |
129 |
| - } |
130 |
| - if (name().isPresent()) { |
131 |
| - desc = DynamicConstantDesc.ofNamed(BSM_INVOKE, "withName", desc.constantType(), MH_WITH_NAME, |
132 |
| - desc, name().get().describeConstable().orElseThrow()); |
133 |
| - } |
134 |
| - |
135 |
| - return desc; |
136 |
| - } |
137 |
| - |
138 | 112 | boolean hasNaturalAlignment() {
|
139 | 113 | return size == alignment;
|
140 | 114 | }
|
@@ -186,49 +160,4 @@ public boolean equals(Object that) {
|
186 | 160 | * {@return the string representation of this layout}
|
187 | 161 | */
|
188 | 162 | public abstract String toString();
|
189 |
| - |
190 |
| - /*** Helper constants for implementing Layout::describeConstable ***/ |
191 |
| - |
192 |
| - static final ClassDesc CD_MEMORY_LAYOUT = MemoryLayout.class.describeConstable().get(); |
193 |
| - |
194 |
| - static final ClassDesc CD_VALUE_LAYOUT = ValueLayout.class.describeConstable().get(); |
195 |
| - |
196 |
| - static final ClassDesc CD_SEQUENCE_LAYOUT = SequenceLayout.class.describeConstable().get(); |
197 |
| - |
198 |
| - static final ClassDesc CD_GROUP_LAYOUT = GroupLayout.class.describeConstable().get(); |
199 |
| - |
200 |
| - static final ClassDesc CD_BYTEORDER = ByteOrder.class.describeConstable().get(); |
201 |
| - |
202 |
| - static final ClassDesc CD_FUNCTION_DESC = FunctionDescriptor.class.describeConstable().get(); |
203 |
| - |
204 |
| - static final ConstantDesc BIG_ENDIAN = DynamicConstantDesc.ofNamed(BSM_GET_STATIC_FINAL, "BIG_ENDIAN", CD_BYTEORDER, CD_BYTEORDER); |
205 |
| - |
206 |
| - static final ConstantDesc LITTLE_ENDIAN = DynamicConstantDesc.ofNamed(BSM_GET_STATIC_FINAL, "LITTLE_ENDIAN", CD_BYTEORDER, CD_BYTEORDER); |
207 |
| - |
208 |
| - static final MethodHandleDesc MH_PADDING = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.INTERFACE_STATIC, CD_MEMORY_LAYOUT, "paddingLayout", |
209 |
| - MethodTypeDesc.of(CD_MEMORY_LAYOUT, CD_long)); |
210 |
| - |
211 |
| - static final MethodHandleDesc MH_SIZED_SEQUENCE = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.INTERFACE_STATIC, CD_MEMORY_LAYOUT, "sequenceLayout", |
212 |
| - MethodTypeDesc.of(CD_SEQUENCE_LAYOUT, CD_long, CD_MEMORY_LAYOUT)); |
213 |
| - |
214 |
| - static final MethodHandleDesc MH_STRUCT = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.INTERFACE_STATIC, CD_MEMORY_LAYOUT, "structLayout", |
215 |
| - MethodTypeDesc.of(CD_GROUP_LAYOUT, CD_MEMORY_LAYOUT.arrayType())); |
216 |
| - |
217 |
| - static final MethodHandleDesc MH_UNION = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.INTERFACE_STATIC, CD_MEMORY_LAYOUT, "unionLayout", |
218 |
| - MethodTypeDesc.of(CD_GROUP_LAYOUT, CD_MEMORY_LAYOUT.arrayType())); |
219 |
| - |
220 |
| - static final MethodHandleDesc MH_VALUE = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.INTERFACE_STATIC, CD_MEMORY_LAYOUT, "valueLayout", |
221 |
| - MethodTypeDesc.of(CD_VALUE_LAYOUT, CD_Class, CD_BYTEORDER)); |
222 |
| - |
223 |
| - static final MethodHandleDesc MH_VOID_FUNCTION = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.STATIC, CD_FUNCTION_DESC, "ofVoid", |
224 |
| - MethodTypeDesc.of(CD_FUNCTION_DESC, CD_MEMORY_LAYOUT.arrayType())); |
225 |
| - |
226 |
| - static final MethodHandleDesc MH_FUNCTION = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.STATIC, CD_FUNCTION_DESC, "of", |
227 |
| - MethodTypeDesc.of(CD_FUNCTION_DESC, CD_MEMORY_LAYOUT, CD_MEMORY_LAYOUT.arrayType())); |
228 |
| - |
229 |
| - static final MethodHandleDesc MH_WITH_BIT_ALIGNMENT = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.INTERFACE_VIRTUAL, CD_MEMORY_LAYOUT, "withBitAlignment", |
230 |
| - MethodTypeDesc.of(CD_MEMORY_LAYOUT, CD_long)); |
231 |
| - |
232 |
| - static final MethodHandleDesc MH_WITH_NAME = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.INTERFACE_VIRTUAL, CD_MEMORY_LAYOUT, "withName", |
233 |
| - MethodTypeDesc.of(CD_MEMORY_LAYOUT, CD_String)); |
234 | 163 | }
|
0 commit comments