mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-03 05:44:10 -08:00
Fix bugs in Wasi support. Fix GC issue in Wasm
This commit is contained in:
parent
1b6acc9eb1
commit
d9fb2bc159
|
@ -69,7 +69,6 @@ public final class WasmHeap {
|
|||
|
||||
public static void initHeap(Address start, int minHeap, int maxHeap, int stackSize, int bufferSize) {
|
||||
initHeapTrace(maxHeap);
|
||||
buffer = start;
|
||||
buffer = WasmRuntime.align(start, 16);
|
||||
WasmHeap.bufferSize = bufferSize;
|
||||
stack = WasmRuntime.align(buffer.add(bufferSize), 16);
|
||||
|
|
|
@ -112,8 +112,8 @@ public class WasiSupport {
|
|||
if (errno != ERRNO_SUCCESS) {
|
||||
throw new RuntimeException("Could not get command line arguments");
|
||||
}
|
||||
int argvSize = (int) sizesReceiver.value;
|
||||
int argvBufSize = (int) bufferSizeReceiver.value;
|
||||
int argvSize = sizesReceiver.value;
|
||||
int argvBufSize = bufferSizeReceiver.value;
|
||||
|
||||
int[] argvOffsets = new int[argvSize];
|
||||
byte[] argvBuffer = new byte[argvBufSize];
|
||||
|
|
|
@ -60,10 +60,11 @@ public class Characteristics {
|
|||
public boolean isResource(String className) {
|
||||
byte result = isResource.getOrDefault(className, (byte) -1);
|
||||
if (result < 0) {
|
||||
if (className.equals("org/teavm/platform/metadata/Resource")) {
|
||||
if (className.equals("org.teavm.platform.metadata.Resource")) {
|
||||
result = 1;
|
||||
} else {
|
||||
ClassReader cls = classSource.get(className);
|
||||
result = 0;
|
||||
if (cls != null) {
|
||||
if (cls.getParent() != null) {
|
||||
result = isResource(cls.getParent()) ? (byte) 1 : 0;
|
||||
|
|
|
@ -141,19 +141,19 @@ public final class ExceptionHandling {
|
|||
|
||||
@Unmanaged
|
||||
public static void throwClassCastException() {
|
||||
throw new ClassCastException();
|
||||
throwException(new ClassCastException());
|
||||
}
|
||||
|
||||
@Unmanaged
|
||||
@Export(name = "teavm_throwNullPointerException")
|
||||
public static void throwNullPointerException() {
|
||||
throw new NullPointerException();
|
||||
throwException(new NullPointerException());
|
||||
}
|
||||
|
||||
@Unmanaged
|
||||
@Export(name = "teavm_throwArrayIndexOutOfBoundsException")
|
||||
public static void throwArrayIndexOutOfBoundsException() {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
throwException(new ArrayIndexOutOfBoundsException());
|
||||
}
|
||||
|
||||
@Unmanaged
|
||||
|
|
|
@ -92,7 +92,7 @@ int32_t wasi_snapshot_preview1_args_sizes_get(int32_t argv_size, int32_t argv_bu
|
|||
|
||||
int32_t bufferSize = 0;
|
||||
for (int i = 0; i < wasm_args; ++i) {
|
||||
bufferSize += (int32_t) strlen(wasm_argv[i]);
|
||||
bufferSize += (int32_t) strlen(wasm_argv[i]) + 1;
|
||||
}
|
||||
*argvBufferSizePtr = bufferSize;
|
||||
return 0;
|
||||
|
@ -103,8 +103,8 @@ int32_t wasi_snapshot_preview1_args_get(int32_t sizes_ptr, int32_t args_ptr) {
|
|||
char* argsPtr = (char*) (wasm_heap + args_ptr);
|
||||
int offset = 0;
|
||||
for (int i = 0; i < wasm_args; ++i) {
|
||||
sizesPtr[i] = (int32_t) offset;
|
||||
int len = strlen(wasm_argv[i]);
|
||||
sizesPtr[i] = (int32_t) offset + args_ptr;
|
||||
int len = strlen(wasm_argv[i]) + 1;
|
||||
memcpy(argsPtr + offset, wasm_argv[i], len);
|
||||
offset += len;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user