Merge main into dev/socket

This commit is contained in:
Wenyong Huang
2022-09-10 22:12:43 +08:00
74 changed files with 1478 additions and 646 deletions

View File

@ -125,23 +125,24 @@ int
gc_destroy_with_pool(gc_handle_t handle)
{
gc_heap_t *heap = (gc_heap_t *)handle;
int ret = GC_SUCCESS;
#if BH_ENABLE_GC_VERIFY != 0
hmu_t *cur = (hmu_t *)heap->base_addr;
hmu_t *end = (hmu_t *)((char *)heap->base_addr + heap->current_size);
if (!heap->is_heap_corrupted
&& (hmu_t *)((char *)cur + hmu_get_size(cur)) != end) {
os_printf("Memory leak detected:\n");
gci_dump(heap);
#if WASM_ENABLE_SPEC_TEST != 0
while (1) {
}
#endif
ret = GC_ERROR;
}
#endif
os_mutex_destroy(&heap->lock);
memset(heap->base_addr, 0, heap->current_size);
memset(heap, 0, sizeof(gc_heap_t));
return GC_SUCCESS;
return ret;
}
uint32

View File

@ -25,10 +25,10 @@ mem_allocator_create_with_struct_and_pool(void *struct_buf,
pool_buf, pool_buf_size);
}
void
int
mem_allocator_destroy(mem_allocator_t allocator)
{
gc_destroy_with_pool((gc_handle_t)allocator);
return gc_destroy_with_pool((gc_handle_t)allocator);
}
uint32
@ -69,6 +69,13 @@ mem_allocator_is_heap_corrupted(mem_allocator_t allocator)
return gc_is_heap_corrupted((gc_handle_t)allocator);
}
bool
mem_allocator_get_alloc_info(mem_allocator_t allocator, void *mem_alloc_info)
{
gc_heap_stats((gc_handle_t)allocator, mem_alloc_info, 3);
return true;
}
#else /* else of DEFAULT_MEM_ALLOCATOR */
#include "tlsf/tlsf.h"

View File

@ -6,6 +6,10 @@ set (MEM_ALLOC_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(${MEM_ALLOC_DIR})
if (WAMR_BUILD_GC_VERIFY EQUAL 1)
add_definitions (-DBH_ENABLE_GC_VERIFY=1)
endif ()
file (GLOB_RECURSE source_all
${MEM_ALLOC_DIR}/ems/*.c
${MEM_ALLOC_DIR}/tlsf/*.c

View File

@ -23,7 +23,7 @@ mem_allocator_create_with_struct_and_pool(void *struct_buf,
void *pool_buf,
uint32_t pool_buf_size);
void
int
mem_allocator_destroy(mem_allocator_t allocator);
uint32
@ -45,6 +45,9 @@ mem_allocator_migrate(mem_allocator_t allocator, char *pool_buf_new,
bool
mem_allocator_is_heap_corrupted(mem_allocator_t allocator);
bool
mem_allocator_get_alloc_info(mem_allocator_t allocator, void *mem_alloc_info);
#ifdef __cplusplus
}
#endif

View File

@ -30,6 +30,7 @@ typedef aos_task_t korp_thread;
typedef korp_thread *korp_tid;
typedef aos_task_t *aos_tid_t;
typedef aos_mutex_t korp_mutex;
typedef aos_sem_t korp_sem;
struct os_thread_wait_node;
typedef struct os_thread_wait_node *os_thread_wait_list;

View File

@ -59,7 +59,7 @@ bh_list_init(bh_list *list);
* <code>BH_LIST_ERROR</code> if input is invalid or no memory
* available.
*/
extern bh_list_status
bh_list_status
bh_list_insert(bh_list *list, void *elem);
/**