mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 13:16:26 +00:00
Change llvm void pointer to i8 pointer to avoid assert failed (#250)
This commit is contained in:
parent
44ccfd20ad
commit
7abd1ca813
|
@ -192,7 +192,6 @@ typedef enum FloatArithmetic {
|
||||||
#define INT64_PTR_TYPE comp_ctx->basic_types.int64_ptr_type
|
#define INT64_PTR_TYPE comp_ctx->basic_types.int64_ptr_type
|
||||||
#define F32_PTR_TYPE comp_ctx->basic_types.float32_ptr_type
|
#define F32_PTR_TYPE comp_ctx->basic_types.float32_ptr_type
|
||||||
#define F64_PTR_TYPE comp_ctx->basic_types.float64_ptr_type
|
#define F64_PTR_TYPE comp_ctx->basic_types.float64_ptr_type
|
||||||
#define VOID_PTR_TYPE comp_ctx->basic_types.void_ptr_type
|
|
||||||
|
|
||||||
#define I32_CONST(v) LLVMConstInt(I32_TYPE, v, true)
|
#define I32_CONST(v) LLVMConstInt(I32_TYPE, v, true)
|
||||||
#define I64_CONST(v) LLVMConstInt(I64_TYPE, v, true)
|
#define I64_CONST(v) LLVMConstInt(I64_TYPE, v, true)
|
||||||
|
|
|
@ -583,7 +583,7 @@ aot_compile_op_memory_grow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
|
|
||||||
/* To be simple, call wasm_runtime_set_exception() no matter
|
/* To be simple, call wasm_runtime_set_exception() no matter
|
||||||
enlarge success or not */
|
enlarge success or not */
|
||||||
param_types[1] = VOID_PTR_TYPE;
|
param_types[1] = INT8_PTR_TYPE;
|
||||||
ret_type = VOID_TYPE;
|
ret_type = VOID_TYPE;
|
||||||
if (!(func_type = LLVMFunctionType(ret_type, param_types, 2, false))) {
|
if (!(func_type = LLVMFunctionType(ret_type, param_types, 2, false))) {
|
||||||
aot_set_last_error("llvm add function type failed.");
|
aot_set_last_error("llvm add function type failed.");
|
||||||
|
@ -614,7 +614,7 @@ aot_compile_op_memory_grow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call function wasm_runtime_set_exception(aot_inst, NULL) */
|
/* Call function wasm_runtime_set_exception(aot_inst, NULL) */
|
||||||
param_values[1] = LLVMConstNull(VOID_PTR_TYPE);
|
param_values[1] = LLVMConstNull(INT8_PTR_TYPE);
|
||||||
CHECK_LLVM_CONST(param_values[1]);
|
CHECK_LLVM_CONST(param_values[1]);
|
||||||
if (!(LLVMBuildCall(comp_ctx->builder, func, param_values, 2, ""))) {
|
if (!(LLVMBuildCall(comp_ctx->builder, func, param_values, 2, ""))) {
|
||||||
aot_set_last_error("llvm build call failed.");
|
aot_set_last_error("llvm build call failed.");
|
||||||
|
|
|
@ -359,45 +359,6 @@ create_cur_exception(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
create_func_ptrs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
|
||||||
{
|
|
||||||
LLVMValueRef offset, func_ptrs_ptr;
|
|
||||||
LLVMTypeRef void_ptr_type;
|
|
||||||
|
|
||||||
offset = I32_CONST(offsetof(AOTModuleInstance, func_ptrs.ptr));
|
|
||||||
func_ptrs_ptr = LLVMBuildInBoundsGEP(comp_ctx->builder,
|
|
||||||
func_ctx->aot_inst,
|
|
||||||
&offset, 1,
|
|
||||||
"func_ptrs_ptr");
|
|
||||||
if (!func_ptrs_ptr) {
|
|
||||||
aot_set_last_error("llvm build in bounds gep failed.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(void_ptr_type = LLVMPointerType(VOID_PTR_TYPE, 0))
|
|
||||||
|| !(void_ptr_type = LLVMPointerType(void_ptr_type, 0))) {
|
|
||||||
aot_set_last_error("llvm get pointer type failed.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
func_ctx->func_ptrs = LLVMBuildBitCast(comp_ctx->builder, func_ptrs_ptr,
|
|
||||||
void_ptr_type, "func_ptrs_tmp");
|
|
||||||
if (!func_ctx->func_ptrs) {
|
|
||||||
aot_set_last_error("llvm build bit cast failed.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
func_ctx->func_ptrs = LLVMBuildLoad(comp_ctx->builder, func_ctx->func_ptrs,
|
|
||||||
"func_ptrs");
|
|
||||||
if (!func_ctx->func_ptrs) {
|
|
||||||
aot_set_last_error("llvm build load failed.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_func_type_indexes(AOTCompContext *comp_ctx,
|
create_func_type_indexes(AOTCompContext *comp_ctx,
|
||||||
AOTFuncContext *func_ctx)
|
AOTFuncContext *func_ctx)
|
||||||
|
@ -636,10 +597,6 @@ aot_create_func_context(AOTCompData *comp_data, AOTCompContext *comp_ctx,
|
||||||
if (!create_cur_exception(comp_ctx, func_ctx))
|
if (!create_cur_exception(comp_ctx, func_ctx))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Load function pointers */
|
|
||||||
if (!create_func_ptrs(comp_ctx, func_ctx))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
/* Load function type indexes */
|
/* Load function type indexes */
|
||||||
if (!create_func_type_indexes(comp_ctx, func_ctx))
|
if (!create_func_type_indexes(comp_ctx, func_ctx))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -723,7 +680,6 @@ aot_set_llvm_basic_types(AOTLLVMTypes *basic_types, LLVMContextRef context)
|
||||||
basic_types->int64_ptr_type = LLVMPointerType(basic_types->int64_type, 0);
|
basic_types->int64_ptr_type = LLVMPointerType(basic_types->int64_type, 0);
|
||||||
basic_types->float32_ptr_type = LLVMPointerType(basic_types->float32_type, 0);
|
basic_types->float32_ptr_type = LLVMPointerType(basic_types->float32_type, 0);
|
||||||
basic_types->float64_ptr_type = LLVMPointerType(basic_types->float64_type, 0);
|
basic_types->float64_ptr_type = LLVMPointerType(basic_types->float64_type, 0);
|
||||||
basic_types->void_ptr_type = LLVMPointerType(basic_types->void_type, 0);
|
|
||||||
|
|
||||||
return (basic_types->int8_ptr_type
|
return (basic_types->int8_ptr_type
|
||||||
&& basic_types->int16_ptr_type
|
&& basic_types->int16_ptr_type
|
||||||
|
@ -731,7 +687,6 @@ aot_set_llvm_basic_types(AOTLLVMTypes *basic_types, LLVMContextRef context)
|
||||||
&& basic_types->int64_ptr_type
|
&& basic_types->int64_ptr_type
|
||||||
&& basic_types->float32_ptr_type
|
&& basic_types->float32_ptr_type
|
||||||
&& basic_types->float64_ptr_type
|
&& basic_types->float64_ptr_type
|
||||||
&& basic_types->void_ptr_type
|
|
||||||
&& basic_types->meta_data_type) ? true : false;
|
&& basic_types->meta_data_type) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,6 @@ typedef struct AOTFuncContext {
|
||||||
LLVMBasicBlockRef got_exception_block;
|
LLVMBasicBlockRef got_exception_block;
|
||||||
LLVMBasicBlockRef func_return_block;
|
LLVMBasicBlockRef func_return_block;
|
||||||
LLVMValueRef exception_id_phi;
|
LLVMValueRef exception_id_phi;
|
||||||
LLVMValueRef func_ptrs;
|
|
||||||
LLVMValueRef func_type_indexes;
|
LLVMValueRef func_type_indexes;
|
||||||
LLVMValueRef locals[1];
|
LLVMValueRef locals[1];
|
||||||
} AOTFuncContext;
|
} AOTFuncContext;
|
||||||
|
@ -143,7 +142,6 @@ typedef struct AOTLLVMTypes {
|
||||||
LLVMTypeRef int64_ptr_type;
|
LLVMTypeRef int64_ptr_type;
|
||||||
LLVMTypeRef float32_ptr_type;
|
LLVMTypeRef float32_ptr_type;
|
||||||
LLVMTypeRef float64_ptr_type;
|
LLVMTypeRef float64_ptr_type;
|
||||||
LLVMTypeRef void_ptr_type;
|
|
||||||
|
|
||||||
LLVMTypeRef meta_data_type;
|
LLVMTypeRef meta_data_type;
|
||||||
} AOTLLVMTypes;
|
} AOTLLVMTypes;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user