Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Nov 17, 2024
1 parent f70e8eb commit 4ce5a49
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/main/java/overrun/marshal/Downcall.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private static Map.Entry<byte[], DirectAccessData> buildBytecode(MethodHandles.L
codeBuilder -> {
if (returnType == MethodHandle.class) {
// returns MethodHandle
codeBuilder.ldc(DynamicConstantDesc.ofNamed(BSM_DowncallFactory_downcallHandle,
codeBuilder.loadConstant(DynamicConstantDesc.ofNamed(BSM_DowncallFactory_downcallHandle,
entrypoint,
CD_MethodHandle,
DCD_classData_DirectAccessData)
Expand Down Expand Up @@ -418,7 +418,7 @@ private static Map.Entry<byte[], DirectAccessData> buildBytecode(MethodHandles.L
MTD_DirectAccessData,
ACC_PUBLIC,
codeBuilder -> codeBuilder
.ldc(DCD_classData_DirectAccessData)
.loadConstant(DCD_classData_DirectAccessData)
.areturn());
}
//endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static boolean process(CodeBuilder builder, String charset) {
case "UTF_8", "ISO_8859_1", "US_ASCII",
"UTF_16", "UTF_16BE", "UTF_16LE",
"UTF_32", "UTF_32BE", "UTF_32LE" -> builder.getstatic(CD_StandardCharsets, upperCase, CD_Charset);
default -> builder.ldc(upperCase)
default -> builder.loadConstant(upperCase)
.invokestatic(CD_Charset, "forName", MTD_Charset_String);
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void process(CodeBuilder builder, Context context) {
if (parameter.getType().isArray()) {
Sized sized = parameter.getDeclaredAnnotation(Sized.class);
if (sized != null) {
builder.ldc(sized.value())
builder.loadConstant(sized.value())
.aload(builder.parameterSlot(i))
.arraylength()
.invokestatic(CD_Checks,
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/overrun/marshal/struct/StructAllocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private static byte[] buildBytecode(MethodHandles.Lookup lookup, StructLayout la

// Struct implementation
classBuilder.withMethodBody("layout", MTD_StructLayout, Modifier.PUBLIC, codeBuilder -> codeBuilder
.ldc(DCD_classData_StructLayout)
.loadConstant(DCD_classData_StructLayout)
.areturn());
classBuilder.withMethodBody("segment", MTD_MemorySegment, Modifier.PUBLIC, codeBuilder -> codeBuilder
.aload(codeBuilder.receiverSlot())
Expand All @@ -216,15 +216,15 @@ private static byte[] buildBytecode(MethodHandles.Lookup lookup, StructLayout la
.dup()
.aload(codeBuilder.receiverSlot())
.getfield(cd_thisClass, "_segment", CD_MemorySegment)
.ldc(DCD_classData_StructLayout)
.loadConstant(DCD_classData_StructLayout)
.lconst_0()
.lload(codeBuilder.parameterSlot(0))
.invokeinterface(CD_StructLayout, "scale", MTD_long_long_long)
.ldc(DCD_classData_StructLayout)
.loadConstant(DCD_classData_StructLayout)
.lconst_0()
.lload(codeBuilder.parameterSlot(1))
.invokeinterface(CD_StructLayout, "scale", MTD_long_long_long)
.ldc(DCD_classData_StructLayout)
.loadConstant(DCD_classData_StructLayout)
.invokeinterface(CD_StructLayout, "byteAlignment", MTD_long)
.invokeinterface(CD_MemorySegment, "asSlice", MTD_MemorySegment_long_long_long)
.lload(codeBuilder.parameterSlot(1))
Expand All @@ -235,13 +235,13 @@ private static byte[] buildBytecode(MethodHandles.Lookup lookup, StructLayout la
.dup()
.aload(codeBuilder.receiverSlot())
.getfield(cd_thisClass, "_segment", CD_MemorySegment)
.ldc(DCD_classData_StructLayout)
.loadConstant(DCD_classData_StructLayout)
.lconst_0()
.lload(codeBuilder.parameterSlot(0))
.invokeinterface(CD_StructLayout, "scale", MTD_long_long_long)
.ldc(DCD_classData_StructLayout)
.loadConstant(DCD_classData_StructLayout)
.invokeinterface(CD_StructLayout, "byteSize", MTD_long)
.ldc(DCD_classData_StructLayout)
.loadConstant(DCD_classData_StructLayout)
.invokeinterface(CD_StructLayout, "byteAlignment", MTD_long)
.invokeinterface(CD_MemorySegment, "asSlice", MTD_MemorySegment_long_long_long)
.lconst_1()
Expand Down Expand Up @@ -358,21 +358,21 @@ private static byte[] buildBytecode(MethodHandles.Lookup lookup, StructLayout la

for (FindResult result : results) {
// var handle
codeBuilder.ldc(DCD_classData_StructLayout)
.ldc(result.elems().size() + 1)
codeBuilder.loadConstant(DCD_classData_StructLayout)
.loadConstant(result.elems().size() + 1)
.anewarray(CD_MemoryLayout$PathElement)
.dup()
.iconst_0()
.ldc(name)
.loadConstant(name)
.invokestatic(CD_MemoryLayout$PathElement, "groupElement", MTD_MemoryLayout$PathElement_String, true)
.aastore();
int i = 0;
for (Elem elem : result.elems()) {
codeBuilder.dup()
.ldc(i + 1);
.loadConstant(i + 1);
switch (elem) {
case GroupElem groupElem -> codeBuilder
.ldc(groupElem.name)
.loadConstant(groupElem.name)
.invokestatic(CD_MemoryLayout$PathElement, "groupElement", MTD_MemoryLayout$PathElement_String, true);
case SeqElem _ -> codeBuilder
.invokestatic(CD_MemoryLayout$PathElement, "sequenceElement", MTD_MemoryLayout$PathElement, true);
Expand All @@ -388,12 +388,12 @@ private static byte[] buildBytecode(MethodHandles.Lookup lookup, StructLayout la
final String name = valueLayout.name().orElseThrow();

// var handle
codeBuilder.ldc(DCD_classData_StructLayout)
codeBuilder.loadConstant(DCD_classData_StructLayout)
.iconst_1()
.anewarray(CD_MemoryLayout$PathElement)
.dup()
.iconst_0()
.ldc(name)
.loadConstant(name)
.invokestatic(CD_MemoryLayout$PathElement, "groupElement", MTD_MemoryLayout$PathElement_String, true)
.aastore()
.invokeinterface(CD_StructLayout, "varHandle", MTD_VarHandle_MemoryLayout$PathElementArray)
Expand Down

0 comments on commit 4ce5a49

Please sign in to comment.