|
|
@@ -671,9 +671,16 @@ bool
|
|
|
check_suspend_flags(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
|
|
{
|
|
|
LLVMValueRef terminate_addr, terminate_flags, flag, offset, res;
|
|
|
- LLVMBasicBlockRef terminate_check_block, non_terminate_block;
|
|
|
+ LLVMBasicBlockRef terminate_block, non_terminate_block;
|
|
|
AOTFuncType *aot_func_type = func_ctx->aot_func->func_type;
|
|
|
- LLVMBasicBlockRef terminate_block;
|
|
|
+ bool is_shared_memory =
|
|
|
+ comp_ctx->comp_data->memories[0].memory_flags & 0x02 ? true : false;
|
|
|
+
|
|
|
+ /* Only need to check the suspend flags when memory is shared since
|
|
|
+ shared memory must be enabled for multi-threading */
|
|
|
+ if (!is_shared_memory) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
/* Offset of suspend_flags */
|
|
|
offset = I32_FIVE;
|
|
|
@@ -701,29 +708,20 @@ check_suspend_flags(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
|
|
will always be loaded from memory rather than register */
|
|
|
LLVMSetVolatile(terminate_flags, true);
|
|
|
|
|
|
- CREATE_BLOCK(terminate_check_block, "terminate_check");
|
|
|
- MOVE_BLOCK_AFTER_CURR(terminate_check_block);
|
|
|
+ if (!(flag = LLVMBuildAnd(comp_ctx->builder, terminate_flags, I32_ONE,
|
|
|
+ "termination_flag"))) {
|
|
|
+ aot_set_last_error("llvm build AND failed");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
CREATE_BLOCK(non_terminate_block, "non_terminate");
|
|
|
MOVE_BLOCK_AFTER_CURR(non_terminate_block);
|
|
|
|
|
|
- BUILD_ICMP(LLVMIntSGT, terminate_flags, I32_ZERO, res, "need_terminate");
|
|
|
- BUILD_COND_BR(res, terminate_check_block, non_terminate_block);
|
|
|
-
|
|
|
- /* Move builder to terminate check block */
|
|
|
- SET_BUILDER_POS(terminate_check_block);
|
|
|
-
|
|
|
CREATE_BLOCK(terminate_block, "terminate");
|
|
|
MOVE_BLOCK_AFTER_CURR(terminate_block);
|
|
|
|
|
|
- if (!(flag = LLVMBuildAnd(comp_ctx->builder, terminate_flags, I32_ONE,
|
|
|
- "termination_flag"))) {
|
|
|
- aot_set_last_error("llvm build AND failed");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- BUILD_ICMP(LLVMIntSGT, flag, I32_ZERO, res, "need_terminate");
|
|
|
- BUILD_COND_BR(res, terminate_block, non_terminate_block);
|
|
|
+ BUILD_ICMP(LLVMIntEQ, flag, I32_ZERO, res, "flag_terminate");
|
|
|
+ BUILD_COND_BR(res, non_terminate_block, terminate_block);
|
|
|
|
|
|
/* Move builder to terminate block */
|
|
|
SET_BUILDER_POS(terminate_block);
|