@@ -267,130 +267,6 @@ call_aot_invoke_native_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
267267 return true;
268268}
269269
270- /*TODO: maybe no need to do that*/
271- static bool
272- lookup_orcjit_func (AOTCompContext * comp_ctx , AOTFuncContext * func_ctx ,
273- LLVMValueRef func_idx , LLVMValueRef * p_func )
274- {
275- LLVMBasicBlockRef block_curr , block_resolve_func , block_func_resolved ;
276- LLVMValueRef param_values [3 ], func , value , func_ptr , cmp , phi ;
277- LLVMTypeRef param_types [3 ], ret_type , func_type , func_ptr_type ;
278-
279- block_curr = LLVMGetInsertBlock (comp_ctx -> builder );
280-
281- if (!(block_resolve_func = LLVMAppendBasicBlockInContext (
282- comp_ctx -> context , func_ctx -> func , "resolve_func" ))) {
283- aot_set_last_error ("llvm add basic block failed." );
284- return false;
285- }
286- if (!(block_func_resolved = LLVMAppendBasicBlockInContext (
287- comp_ctx -> context , func_ctx -> func , "func_resolved" ))) {
288- aot_set_last_error ("llvm add basic block failed." );
289- return false;
290- }
291- LLVMMoveBasicBlockAfter (block_resolve_func , block_curr );
292- LLVMMoveBasicBlockAfter (block_func_resolved , block_resolve_func );
293-
294- LLVMPositionBuilderAtEnd (comp_ctx -> builder , block_func_resolved );
295- if (!(phi = LLVMBuildPhi (comp_ctx -> builder , INT8_PTR_TYPE , "phi" ))) {
296- aot_set_last_error ("llvm build phi failed." );
297- return false;
298- }
299-
300- LLVMPositionBuilderAtEnd (comp_ctx -> builder , block_curr );
301-
302- /* Load function pointer */
303- if (!(func_ptr = LLVMBuildInBoundsGEP2 (comp_ctx -> builder , OPQ_PTR_TYPE ,
304- func_ctx -> func_ptrs , & func_idx , 1 ,
305- "func_ptr_tmp" ))) {
306- aot_set_last_error ("llvm build inbounds gep failed." );
307- return false;
308- }
309-
310- if (!(func = LLVMBuildLoad2 (comp_ctx -> builder , OPQ_PTR_TYPE , func_ptr ,
311- "func_ptr" ))) {
312- aot_set_last_error ("llvm build load failed." );
313- return false;
314- }
315-
316- /* If func ptr is NULL, call aot_lookup_orcjit_func to resolve it */
317- if (!(cmp = LLVMBuildIsNull (comp_ctx -> builder , func , "cmp" ))) {
318- aot_set_last_error ("llvm build is null failed" );
319- return false;
320- }
321-
322- /* Create condition br */
323- if (!LLVMBuildCondBr (comp_ctx -> builder , cmp , block_resolve_func ,
324- block_func_resolved )) {
325- aot_set_last_error ("llvm build cond br failed." );
326- return false;
327- }
328- LLVMAddIncoming (phi , & func , & block_curr , 1 );
329-
330- LLVMPositionBuilderAtEnd (comp_ctx -> builder , block_resolve_func );
331-
332- param_types [0 ] = INT8_PTR_TYPE ;
333- param_types [1 ] = comp_ctx -> aot_inst_type ;
334- param_types [2 ] = I32_TYPE ;
335- ret_type = INT8_PTR_TYPE ;
336-
337- if (!(func_type = LLVMFunctionType (ret_type , param_types , 3 , false))
338- || !(func_ptr_type = LLVMPointerType (func_type , 0 ))) {
339- aot_set_last_error ("llvm add function type failed." );
340- return false;
341- }
342-
343- if (!(value = I64_CONST ((uint64 )(uintptr_t )aot_lookup_orcjit_func ))
344- || !(func = LLVMConstIntToPtr (value , func_ptr_type ))) {
345- aot_set_last_error ("create LLVM value failed." );
346- return false;
347- }
348-
349- param_values [0 ] = I64_CONST ((uintptr_t )comp_ctx -> orc_jit );
350- if (!param_values [0 ]) {
351- aot_set_last_error ("llvm build const failed." );
352- return false;
353- }
354- if (!(param_values [0 ] =
355- LLVMConstIntToPtr (param_values [0 ], INT8_PTR_TYPE ))) {
356- aot_set_last_error ("llvm build bit cast failed." );
357- return false;
358- }
359-
360- param_values [1 ] = func_ctx -> aot_inst ;
361-
362- param_values [2 ] = func_idx ;
363- if (!param_values [2 ]) {
364- aot_set_last_error ("llvm build const failed." );
365- return false;
366- }
367-
368- /* Call the function */
369- if (!(func = LLVMBuildCall2 (comp_ctx -> builder , func_type , func ,
370- param_values , 3 , "call_orcjit_lookup" ))) {
371- aot_set_last_error ("LLVM build call failed." );
372- return false;
373- }
374-
375- /* Check whether exception was thrown when looking up func */
376- if (!check_exception_thrown (comp_ctx , func_ctx )) {
377- return false;
378- }
379-
380- block_curr = LLVMGetInsertBlock (comp_ctx -> builder );
381- LLVMAddIncoming (phi , & func , & block_curr , 1 );
382-
383- if (!LLVMBuildBr (comp_ctx -> builder , block_func_resolved )) {
384- aot_set_last_error ("llvm build br failed." );
385- return false;
386- }
387-
388- LLVMPositionBuilderAtEnd (comp_ctx -> builder , block_func_resolved );
389-
390- * p_func = phi ;
391- return true;
392- }
393-
394270#if (WASM_ENABLE_DUMP_CALL_STACK != 0 ) || (WASM_ENABLE_PERF_PROFILING != 0 )
395271static bool
396272call_aot_alloc_frame_func (AOTCompContext * comp_ctx , AOTFuncContext * func_ctx ,
@@ -909,35 +785,6 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
909785 else {
910786 func = func_ctxes [func_idx - import_func_count ]-> func ;
911787 }
912- // else {
913- // LLVMTypeRef func_ptr_type;
914- // LLVMValueRef func_idx_const = I32_CONST(func_idx);
915-
916- // if (!func_idx_const) {
917- // aot_set_last_error("llvm build const failed.");
918- // goto fail;
919- // }
920-
921- // /* For LAZY JIT, each function belongs to its own module,
922- // we call aot_lookup_orcjit_func to get the func pointer */
923- // if (!lookup_orcjit_func(comp_ctx, func_ctx, func_idx_const,
924- // &func)) {
925- // goto fail;
926- // }
927-
928- // if (!(func_ptr_type = LLVMPointerType(
929- // func_ctxes[func_idx -
930- // import_func_count]->func_type, 0))) {
931- // aot_set_last_error("construct func ptr type failed.");
932- // goto fail;
933- // }
934-
935- // if (!(func = LLVMBuildBitCast(comp_ctx->builder, func,
936- // func_ptr_type, "aot_func"))) {
937- // aot_set_last_error("llvm bit cast failed.");
938- // goto fail;
939- // }
940- // }
941788 }
942789
943790 aot_func = func_ctxes [func_idx - import_func_count ]-> aot_func ;
@@ -1580,11 +1427,6 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
15801427 goto fail ;
15811428 }
15821429
1583- // /* For LAZY JIT, each function belongs to its own module,
1584- // we call aot_lookup_orcjit_func to get the func pointer */
1585- // if (!lookup_orcjit_func(comp_ctx, func_ctx, func_idx, &func_ptr))
1586- // goto fail;
1587-
15881430 if (!(llvm_func_type =
15891431 LLVMFunctionType (ret_type , param_types , total_param_count , false))
15901432 || !(llvm_func_ptr_type = LLVMPointerType (llvm_func_type , 0 ))) {
0 commit comments