Enable WASI feature, enhance security and add SGX sample (#142)
Change emcc to clang Refine interpreter to improve perforamnce
This commit is contained in:
@ -95,7 +95,7 @@ void bh_memory_destroy()
|
||||
memory_mode = MEMORY_MODE_UNKNOWN;
|
||||
}
|
||||
|
||||
int bh_memory_pool_size()
|
||||
unsigned bh_memory_pool_size()
|
||||
{
|
||||
if (memory_mode == MEMORY_MODE_POOL)
|
||||
return global_pool_size;
|
||||
@ -155,7 +155,7 @@ void* bh_malloc_profile(const char *file,
|
||||
profile = bh_malloc_internal(sizeof(memory_profile_t));
|
||||
if (!profile) {
|
||||
vm_mutex_unlock(&profile_lock);
|
||||
memcpy(p, &size, sizeof(size));
|
||||
bh_memcpy_s(p, size + 8, &size, sizeof(size));
|
||||
return (char *)p + 8;
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ void* bh_malloc_profile(const char *file,
|
||||
|
||||
vm_mutex_unlock(&profile_lock);
|
||||
|
||||
memcpy(p, &size, sizeof(size));
|
||||
bh_memcpy_s(p, size + 8, &size, sizeof(size));
|
||||
memory_in_use += size;
|
||||
|
||||
memory_profile_print(file, line, func, size);
|
||||
|
||||
@ -94,7 +94,7 @@ static void unlink_hmu(gc_heap_t *heap, hmu_t *hmu)
|
||||
size = hmu_get_size(hmu);
|
||||
|
||||
if (HMU_IS_FC_NORMAL(size)) {
|
||||
int node_idx = size >> 3;
|
||||
uint32 node_idx = size >> 3;
|
||||
hmu_normal_node_t* node = heap->kfc_normal_list[node_idx].next;
|
||||
hmu_normal_node_t** p = &(heap->kfc_normal_list[node_idx].next);
|
||||
while (node) {
|
||||
@ -120,7 +120,7 @@ static void hmu_set_free_size(hmu_t *hmu)
|
||||
bh_assert(hmu && hmu_get_ut(hmu) == HMU_FC);
|
||||
|
||||
size = hmu_get_size(hmu);
|
||||
*((int*) ((char*) hmu + size) - 1) = size;
|
||||
*((uint32*) ((char*) hmu + size) - 1) = size;
|
||||
}
|
||||
|
||||
/* Add free chunk back to KFC*/
|
||||
@ -135,7 +135,7 @@ void gci_add_fc(gc_heap_t *heap, hmu_t *hmu, gc_size_t size)
|
||||
{
|
||||
hmu_normal_node_t *np = NULL;
|
||||
hmu_tree_node_t *root = NULL, *tp = NULL, *node = NULL;
|
||||
int node_idx;
|
||||
uint32 node_idx;
|
||||
|
||||
bh_assert(gci_is_heap_valid(heap));
|
||||
bh_assert(
|
||||
@ -203,7 +203,7 @@ void gci_add_fc(gc_heap_t *heap, hmu_t *hmu, gc_size_t size)
|
||||
BH_STATIC hmu_t *alloc_hmu(gc_heap_t *heap, gc_size_t size)
|
||||
{
|
||||
hmu_normal_node_t *node = NULL, *p = NULL;
|
||||
int node_idx = 0, init_node_idx = 0;
|
||||
uint32 node_idx = 0, init_node_idx = 0;
|
||||
hmu_tree_node_t *root = NULL, *tp = NULL, *last_tp = NULL;
|
||||
hmu_t *next, *rest;
|
||||
|
||||
@ -216,7 +216,7 @@ BH_STATIC hmu_t *alloc_hmu(gc_heap_t *heap, gc_size_t size)
|
||||
/* check normal list at first*/
|
||||
if (HMU_IS_FC_NORMAL(size)) {
|
||||
/* find a non-empty slot in normal_node_list with good size*/
|
||||
init_node_idx = (int) (size >> 3);
|
||||
init_node_idx = (size >> 3);
|
||||
for (node_idx = init_node_idx; node_idx < HMU_NORMAL_NODE_CNT;
|
||||
node_idx++) {
|
||||
node = heap->kfc_normal_list + node_idx;
|
||||
@ -233,8 +233,8 @@ BH_STATIC hmu_t *alloc_hmu(gc_heap_t *heap, gc_size_t size)
|
||||
node->next = p->next;
|
||||
bh_assert(((gc_int32)(uintptr_t)hmu_to_obj(p) & 7) == 0);
|
||||
|
||||
if ((gc_size_t) node_idx
|
||||
!= init_node_idx&& ((gc_size_t)node_idx << 3) >= size + GC_SMALLEST_SIZE) { /* with bigger size*/
|
||||
if ((gc_size_t)node_idx != (uint32)init_node_idx
|
||||
&& ((gc_size_t)node_idx << 3) >= size + GC_SMALLEST_SIZE) { /* with bigger size*/
|
||||
rest = (hmu_t*) (((char *) p) + size);
|
||||
gci_add_fc(heap, rest, (node_idx << 3) - size);
|
||||
hmu_mark_pinuse(rest);
|
||||
|
||||
@ -169,7 +169,7 @@ extern int gc_destroy_with_pool(gc_handle_t handle);
|
||||
* @param size [in] the size of stats
|
||||
* @param mmt [in] type of heap, MMT_SHARED or MMT_INSTANCE
|
||||
*/
|
||||
extern void* gc_heap_stats(void *heap, int* stats, int size, gc_mm_t mmt);
|
||||
extern void* gc_heap_stats(void *heap, uint32* stats, int size, gc_mm_t mmt);
|
||||
|
||||
/**
|
||||
* Set GC threshold factor
|
||||
|
||||
@ -77,7 +77,7 @@ extern void hmu_verify(hmu_t *hmu);
|
||||
|
||||
#define hmu_obj_size(s) ((s)-OBJ_EXTRA_SIZE)
|
||||
|
||||
#define GC_ALIGN_8(s) (((int)(s) + 7) & ~7)
|
||||
#define GC_ALIGN_8(s) (((uint32)(s) + 7) & (uint32)~7)
|
||||
|
||||
#define GC_SMALLEST_SIZE GC_ALIGN_8(HMU_SIZE + OBJ_PREFIX_SIZE + OBJ_SUFFIX_SIZE + 8)
|
||||
#define GC_GET_REAL_SIZE(x) GC_ALIGN_8(HMU_SIZE + OBJ_PREFIX_SIZE + OBJ_SUFFIX_SIZE + (((x) > 8) ? (x): 8))
|
||||
@ -86,14 +86,14 @@ extern void hmu_verify(hmu_t *hmu);
|
||||
|
||||
#define SETBIT(v, offset) (v) |= (1 << (offset))
|
||||
#define GETBIT(v, offset) ((v) & (1 << (offset)) ? 1 : 0)
|
||||
#define CLRBIT(v, offset) (v) &= ~(1 << (offset))
|
||||
#define CLRBIT(v, offset) (v) &= (uint32)(~(1 << (offset)))
|
||||
|
||||
#define SETBITS(v, offset, size, value) do { \
|
||||
(v) &= ~(((1 << size) - 1) << offset); \
|
||||
(v) |= value << offset; \
|
||||
} while(0)
|
||||
(v) &= (uint32)(~(((1 << size) - 1) << offset));\
|
||||
(v) |= (uint32)(value << offset); \
|
||||
} while(0)
|
||||
#define CLRBITS(v, offset, size) (v) &= ~(((1 << size) - 1) << offset)
|
||||
#define GETBITS(v, offset, size) (((v) & (((1 << size) - 1) << offset)) >> offset)
|
||||
#define GETBITS(v, offset, size) (((v) & ((uint32)(((1 << size) - 1) << offset))) >> offset)
|
||||
|
||||
/*////// gc object layout definition*/
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ int gci_check_platform()
|
||||
gc_handle_t gc_init_with_pool(char *buf, gc_size_t buf_size)
|
||||
{
|
||||
char *buf_end = buf + buf_size;
|
||||
char *buf_aligned = (char*) (((uintptr_t) buf + 7) & ~7);
|
||||
char *buf_aligned = (char*) (((uintptr_t) buf + 7) & (uintptr_t)~7);
|
||||
char *base_addr = buf_aligned + sizeof(gc_heap_t);
|
||||
gc_heap_t *heap = (gc_heap_t*) buf_aligned;
|
||||
gc_size_t heap_max_size;
|
||||
@ -60,8 +60,8 @@ gc_handle_t gc_init_with_pool(char *buf, gc_size_t buf_size)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
base_addr = (char*) (((uintptr_t) base_addr + 7) & ~7) + GC_HEAD_PADDING;
|
||||
heap_max_size = (buf_end - base_addr) & ~7;
|
||||
base_addr = (char*) (((uintptr_t) base_addr + 7) & (uintptr_t)~7) + GC_HEAD_PADDING;
|
||||
heap_max_size = (uint32)(buf_end - base_addr) & (uint32)~7;
|
||||
|
||||
memset(heap, 0, sizeof *heap);
|
||||
memset(base_addr, 0, heap_max_size);
|
||||
@ -154,7 +154,7 @@ void gci_verify_heap(gc_heap_t *heap)
|
||||
}
|
||||
#endif
|
||||
|
||||
void* gc_heap_stats(void *heap_arg, int* stats, int size, gc_mm_t mmt)
|
||||
void* gc_heap_stats(void *heap_arg, uint32* stats, int size, gc_mm_t mmt)
|
||||
{
|
||||
(void) mmt;
|
||||
int i;
|
||||
@ -175,7 +175,7 @@ void* gc_heap_stats(void *heap_arg, int* stats, int size, gc_mm_t mmt)
|
||||
stats[i] = heap->total_gc_count;
|
||||
break;
|
||||
case GC_STAT_TIME:
|
||||
stats[i] = (int) heap->total_gc_time;
|
||||
stats[i] = (uint32)heap->total_gc_time;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user