mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-10-16 05:51:42 +00:00

* shared heap enhancement: modify memory check for aot_check_memory_overflow to accomodate shared heap chain * shared heap enhancement in AOT * use alloca for func ctx shared heap cache value * use correct alloca for func ctx shared heap cache value * enable shared heap chain aot test and bug fix * Fix a missing argument on 32bits platform, still has the shared heap chain iteration problem * Fix shared heap chain iteration problem on 32bits platform * fix AOT bulk memory bounds checks compliation issue * fix AOT bulk memory bounds checks on 64 bits platform * refactor aot memory check * refactor AOT bulk memory bounds checks * add more unit test for shared heap * finished organizing unit test for shared heap and enable x86_32 for shared heap unit test * cover a corner case for bulk memory overflow check * try func call to replace shared heap chain traverse * fix compilation error in JIT and potentially load nullptr * add option for wamrc to enable single shared heap/multi shared heap, and update shared heap unit tests and sample * cr suggestions: 1. check potiential underflow 2. refactor and use separate function for bulk memory and normal memroy 3. static assert 4. add more comments 5. remove unused code
63 lines
958 B
C
63 lines
958 B
C
/*
|
|
* Copyright (C) 2024 Xiaomi Corporation. All rights reserved.
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
*/
|
|
|
|
#define NULL 0
|
|
|
|
extern void *
|
|
shared_heap_malloc(int size);
|
|
extern void
|
|
shared_heap_free(void *offset);
|
|
|
|
int
|
|
test()
|
|
{
|
|
int *ptr = (int *)shared_heap_malloc(4);
|
|
|
|
*ptr = 10;
|
|
int a = *ptr;
|
|
shared_heap_free(ptr);
|
|
return a;
|
|
}
|
|
|
|
int
|
|
test_malloc_fail()
|
|
{
|
|
int *ptr = (int *)shared_heap_malloc(8192);
|
|
|
|
if (ptr == NULL) {
|
|
return 1;
|
|
}
|
|
shared_heap_free(ptr);
|
|
return 0;
|
|
}
|
|
|
|
void *
|
|
my_shared_heap_malloc(int size)
|
|
{
|
|
return shared_heap_malloc(size);
|
|
}
|
|
|
|
void
|
|
my_shared_heap_free(void *addr)
|
|
{
|
|
shared_heap_free(addr);
|
|
}
|
|
|
|
char
|
|
read_modify_write_8(char *addr, char value)
|
|
{
|
|
char original_value = *addr;
|
|
*addr = value;
|
|
return original_value;
|
|
}
|
|
|
|
short
|
|
read_modify_write_16(short *addr, short value)
|
|
{
|
|
short original_value = *addr;
|
|
*addr = value;
|
|
return original_value;
|
|
}
|