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

finishing bulk.wast #281

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@
load.wast,
ref_is_null.wast</orderedWastToProcess>
<excludedTests>
<!-- Init Active/Passive segments -->
SpecV1BulkTest.test91, SpecV1BulkTest.test95, SpecV1BulkTest.test89,
SpecV1BulkTest.test93,
<!-- Invalid and Malformed failures, can be ignored for now -->
SpecV1AddressTest.test199, SpecV1AddressTest.test200, SpecV1AddressTest.test201,
SpecV1AddressTest.test202, SpecV1AddressTest.test203, SpecV1AddressTest.test204,
Expand Down
22 changes: 16 additions & 6 deletions runtime/src/main/java/com/dylibso/chicory/runtime/Machine.java
Original file line number Diff line number Diff line change
Expand Up @@ -1599,13 +1599,23 @@ private static void TABLE_INIT(MStack stack, Instance instance, long[] operands)

var table = instance.table(tableidx);

if (size < 0
|| elementidx > instance.elementCount()
|| instance.element(elementidx) == null
|| !(instance.element(elementidx) instanceof PassiveElement)
|| elemidx + size > instance.element(elementidx).elementCount()
|| end > table.size()) {
var elementCount = instance.elementCount();
var currentElement = instance.element(elementidx);
var currentElementCount =
(currentElement instanceof PassiveElement) ? currentElement.elementCount() : 0;
boolean isOutOfBounds =
(size < 0
|| elementidx > elementCount
|| (size > 0
&& (currentElement == null
|| !(currentElement instanceof PassiveElement)))
|| elemidx + size > currentElementCount
|| end > table.size());

if (isOutOfBounds) {
throw new WASMRuntimeException("out of bounds table access");
} else if (size == 0) {
return;
Comment on lines +1602 to +1618
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is a little bit hard to follow and might make sense to break into some variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, that's the best I could come up with ... but I secretly hope that it will be split and moved to other classes.

}

for (int i = offset; i < end; i++) {
Expand Down