Skip to content

Commit

Permalink
finishing bulk operations
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Apr 18, 2024
1 parent 1987f09 commit a4a63cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
3 changes: 0 additions & 3 deletions runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@
start.wast,
ref_is_null.wast</orderedWastToProcess>
<excludedTests>
<!-- Init Active/Passive segments -->
SpecV1BulkTest.test79, SpecV1BulkTest.test81, SpecV1BulkTest.test83,
SpecV1BulkTest.test85,
<!-- Invalid and Malformed failures, can be ignored for now -->
SpecV1AddressTest.test75, SpecV1AddressTest.test76,
SpecV1AddressTest.test77, SpecV1AddressTest.test78, SpecV1AddressTest.test79,
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 @@ -1597,13 +1597,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;
}

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

0 comments on commit a4a63cd

Please sign in to comment.