Fix copying memory blocks

This commit is contained in:
Alexey Andreev 2016-09-01 12:16:59 +03:00
parent 26749150f6
commit 9fd5a87a00
2 changed files with 8 additions and 8 deletions

View File

@ -110,9 +110,9 @@ public final class Example {
byte[] negatives = new byte[100];
for (int i = 0; i < array.length; ++i) {
array[i] = (byte) i;
negatives[i] = (byte) -i;
negatives[i] = (byte) (-i - 1);
}
System.arraycopy(negatives, 4, array, 0, 12);
System.arraycopy(negatives, 0, array, 4, 12);
System.arraycopy(negatives, 1, array, 21, 12);
System.arraycopy(negatives, 2, array, 35, 12);
System.arraycopy(negatives, 1, array, 8, 3);

View File

@ -262,14 +262,14 @@ public final class WasmRuntime {
alignedTargetStart.putInt(alignedSourceStart.getInt());
break;
case 1:
alignedTargetStart.add(3).putByte(alignedSourceStart.add(3).getByte());
alignedTargetStart.add(1).putByte(alignedSourceStart.add(1).getByte());
alignedTargetStart.add(2).putShort(alignedSourceStart.add(2).getShort());
break;
case 2:
alignedTargetStart.add(2).putShort(alignedSourceStart.add(2).getShort());
break;
case 3:
alignedTargetStart.add(1).putByte(alignedSourceStart.add(1).getByte());
alignedTargetStart.add(2).putShort(alignedSourceStart.add(2).getShort());
alignedTargetStart.add(3).putByte(alignedSourceStart.add(3).getByte());
break;
}
@ -282,7 +282,7 @@ public final class WasmRuntime {
alignedTargetStart = alignedTargetStart.add(4);
}
switch (source.getInt() + count - alignedSourceEnd.getInt()) {
switch (source.toInt() + count - alignedSourceEnd.toInt()) {
case 0:
break;
case 1:
@ -297,7 +297,7 @@ public final class WasmRuntime {
break;
}
} else {
switch (source.getInt() + count - alignedSourceEnd.getInt()) {
switch (source.toInt() + count - alignedSourceEnd.toInt()) {
case 0:
break;
case 1:
@ -312,7 +312,7 @@ public final class WasmRuntime {
break;
}
while (alignedSourceEnd.toInt() > alignedTargetEnd.toInt()) {
while (alignedSourceEnd.toInt() > alignedSourceStart.toInt()) {
alignedTargetEnd.putInt(alignedSourceEnd.getInt());
alignedSourceEnd = alignedSourceEnd.add(-4);
alignedTargetEnd = alignedTargetEnd.add(-4);