Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8343846: [lworld] implement spec changes to stack map tables #1333

Draft
wants to merge 34 commits into
base: lworld
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0cdbcca
8343846: [lworld] implement spec changes to stack map tables
vicente-romero-oracle Nov 8, 2024
a47fbb2
Merge branch 'lworld' into JDK-8343846
vicente-romero-oracle Nov 14, 2024
00a22e3
additional changes
vicente-romero-oracle Nov 14, 2024
9f45b2b
Merge branch 'lworld' into JDK-8343846
vicente-romero-oracle Jan 21, 2025
87fd327
removing duplicate method after merge
vicente-romero-oracle Jan 21, 2025
3b4175f
experiments on classfile API side
vicente-romero-oracle Jan 27, 2025
dbcca52
fixing bugs
vicente-romero-oracle Jan 27, 2025
25a5838
additional cleanup
vicente-romero-oracle Jan 29, 2025
07ddeab
additional cleanup
vicente-romero-oracle Jan 29, 2025
943d644
Merge branch 'JDK-8343846' of https://github.com/vicente-romero-oracl…
vicente-romero-oracle Jan 29, 2025
fb7775c
support for loops, try, switch
vicente-romero-oracle Jan 29, 2025
739b111
fixing bug, array out of bounds
vicente-romero-oracle Jan 30, 2025
9a30940
small verification changes
vicente-romero-oracle Jan 30, 2025
cf906da
add option to generate new stackmap table frame
vicente-romero-oracle Jan 30, 2025
17cb485
Merge branch 'lworld' into JDK-8343846
vicente-romero-oracle Jan 30, 2025
64876e2
removing debug code
vicente-romero-oracle Jan 30, 2025
0d2b44a
minor changes to classfile API
vicente-romero-oracle Jan 31, 2025
dec0a31
fixing minor bug in Gen::visitAssign
vicente-romero-oracle Feb 3, 2025
437610a
clean-ups and refactorings
vicente-romero-oracle Feb 3, 2025
b8ba1dc
debug help
vicente-romero-oracle Feb 4, 2025
4994811
minor refactoring
vicente-romero-oracle Feb 4, 2025
30f9df3
improve javap support
vicente-romero-oracle Feb 4, 2025
26b1130
Some stack maps classfile work, need testing
liach Feb 5, 2025
546de3b
Restore stack map entries for asserts
liach Feb 5, 2025
6b54376
Missing clear
liach Feb 5, 2025
0055365
Merge pull request #1 from liach/fix/cf-unset-fields
vicente-romero-oracle Feb 5, 2025
630e241
adding some test cases
vicente-romero-oracle Feb 5, 2025
9d8a61f
merge with lworld
vicente-romero-oracle Feb 5, 2025
ada284b
refactorings
vicente-romero-oracle Feb 6, 2025
352b1de
additional refactoring
vicente-romero-oracle Feb 6, 2025
bf82dfd
another refactoring
vicente-romero-oracle Feb 7, 2025
55d4ec9
another simplification
vicente-romero-oracle Feb 7, 2025
b258586
refactoring n
vicente-romero-oracle Feb 7, 2025
f98e216
another refactoring
vicente-romero-oracle Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactorings
vicente-romero-oracle committed Feb 6, 2025
commit ada284bd1176264bf89a819c6f975c1f6554dbd9
Original file line number Diff line number Diff line change
@@ -74,12 +74,25 @@ public sealed interface StackMapFrameInfo
* @param target the location of the frame
* @param locals the complete list of frame locals
* @param stack the complete frame stack
* @param unsetFields the complete list of unset fields
*/
public static StackMapFrameInfo of(Label target,
List<VerificationTypeInfo> locals,
List<VerificationTypeInfo> stack,
List<NameAndTypeEntry> unsetFields) {
List<VerificationTypeInfo> stack) {

return of(target, locals, stack, List.of());
}

/**
* {@return a new stack map frame}
* @param target the location of the frame
* @param locals the complete list of frame locals
* @param stack the complete frame stack
* @param unsetFields the complete list of unset fields
*/
public static StackMapFrameInfo of(Label target,
List<VerificationTypeInfo> locals,
List<VerificationTypeInfo> stack,
List<NameAndTypeEntry> unsetFields) {

return new StackMapDecoder.StackMapFrameImpl(255, target, locals, stack, unsetFields);
}
Original file line number Diff line number Diff line change
@@ -597,8 +597,8 @@ private void generateStaticInitializer(ClassBuilder clb) {
.invokespecial(cp.methodRefEntry(ncdfError, exInit))
.athrow();
cob.with(StackMapTableAttribute.of(List.of(
StackMapFrameInfo.of(c1, classLoaderLocal, throwableStack, List.of()),
StackMapFrameInfo.of(c2, classLoaderLocal, throwableStack, List.of()))));
StackMapFrameInfo.of(c1, classLoaderLocal, throwableStack),
StackMapFrameInfo.of(c2, classLoaderLocal, throwableStack))));

});
}
@@ -636,7 +636,6 @@ private void generateLookupAccessor(ClassBuilder clb) {
.with(StackMapTableAttribute.of(List.of(
StackMapFrameInfo.of(failLabel,
List.of(StackMapFrameInfo.ObjectVerificationTypeInfo.of(mhl)),
List.of(),
List.of()))));
}));
}
@@ -735,8 +734,8 @@ private void generateMethod(ClassBuilder clb) {
.invokespecial(uteInit)
.athrow()
.with(StackMapTableAttribute.of(List.of(
StackMapFrameInfo.of(c1, List.of(), throwableStack, List.of()),
StackMapFrameInfo.of(c2, List.of(), throwableStack, List.of()))));
StackMapFrameInfo.of(c1, List.of(), throwableStack),
StackMapFrameInfo.of(c2, List.of(), throwableStack))));
}
}));
}
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ public class StackMapDecoder {
ASSERT_UNSET_FIELDS = 246,
SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247,
SAME_EXTENDED = 251;
private static final int RESERVED_TAGS_UPPER_LIMIT = ASSERT_UNSET_FIELDS; // not inclusive
private static final StackMapFrameInfo[] NO_STACK_FRAME_INFOS = {};

private final ClassReader classReader;
@@ -218,7 +219,7 @@ List<StackMapFrameInfo> entries() {
bci += frameType - 63;
stack = List.of(readVerificationTypeInfo());
} else {
if (frameType < ASSERT_UNSET_FIELDS)
if (frameType < RESERVED_TAGS_UPPER_LIMIT)
throw new IllegalArgumentException("Invalid stackmap frame type: " + frameType);
if (frameType == ASSERT_UNSET_FIELDS) {
unsetFields = readEntryList(p, NameAndTypeEntry.class);
@@ -265,8 +266,7 @@ List<StackMapFrameInfo> entries() {
entries.add(new StackMapFrameImpl(frameType,
label,
locals,
stack,
unsetFields));
stack));
}
return List.copyOf(entries);
}
@@ -348,5 +348,12 @@ public static record StackMapFrameImpl(int frameType,
stack = List.copyOf(stack);
unsetFields = List.copyOf(unsetFields);
}

public StackMapFrameImpl(int frameType,
Label target,
List<VerificationTypeInfo> locals,
List<VerificationTypeInfo> stack) {
this(frameType, target, locals, stack, List.of());
}
}
}
Original file line number Diff line number Diff line change
@@ -163,6 +163,7 @@ void check_verification_type_array_size(int size, int max_size) {
SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247,
SAME_EXTENDED = 251,
FULL = 255;
private static final int RESERVED_TAGS_UPPER_LIMIT = ASSERT_UNSET_FIELDS; // not inclusive

public int get_frame_count() {
return _frame_count;
@@ -279,7 +280,7 @@ public VerificationFrame next(VerificationFrame pre_frame, boolean first, int ma
return frame;
}
int offset_delta = _stream.get_u2();
if (frame_type < ASSERT_UNSET_FIELDS) {
if (frame_type < RESERVED_TAGS_UPPER_LIMIT) {
_verifier.classError("reserved frame type");
}
if (frame_type == SAME_LOCALS_1_STACK_ITEM_EXTENDED) {