Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do aot bounds check by calling native #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

do aot bounds check by calling native #1

wants to merge 2 commits into from

Conversation

WenLY1
Copy link
Owner

@WenLY1 WenLY1 commented Jun 26, 2024

No description provided.

@@ -2728,7 +2728,20 @@ aot_module_realloc_internal(AOTModuleInstance *module_inst,
*p_native_addr = addr;
return (uint64)(addr - memory_inst->memory_data);
}
uintptr_t
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint64

return memory->memory_data + offset;
}
// execption
return 1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return NULL as error

@@ -520,7 +520,9 @@ aot_lookup_function(const AOTModuleInstance *module_inst, const char *name);
*/
AOTFunctionInstance *
aot_get_function_instance(AOTModuleInstance *module_inst, uint32_t func_idx);

uintptr_t
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

#if WASM_ENABLE_AOT_NATIVE_BOUNDS_CHECK == 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@@ -257,6 +257,33 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
&& !(is_local_of_aot_value
&& aot_checked_addr_list_find(func_ctx, local_idx_of_aot_value,
offset, bytes))) {
#if WASM_ENABLE_AOT_NATIVE_BOUNDS_CHECK != 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new param to wamrc to control this behavior

@WenLY1 WenLY1 force-pushed the dev4 branch 3 times, most recently from c2b3a21 to 1da0f59 Compare June 26, 2024 11:01
Signed-off-by: wenlingyun1 <wenlingyun1@xiaomi.com>
@WenLY1 WenLY1 force-pushed the dev4 branch 2 times, most recently from 7cd8b1a to 80e711b Compare July 10, 2024 07:03
{
LLVMValueRef param_values[3], value, maddr, func;
LLVMTypeRef param_types[3], ret_type = 0, func_type = 0, func_ptr_type = 0;
;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

}
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this line

@@ -337,6 +431,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
goto fail;
}
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

LLVMBasicBlockRef incoming_blocks[] = { runtime_bounds_check, check_succ };
LLVMAddIncoming(phi, incoming_values, incoming_blocks, 2);

return phi;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use phi here? How about let aot_bounds_check return offset1 below?

Copy link
Owner Author

@WenLY1 WenLY1 Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we need to check whether the offset is out of bound during runtime, a phi node is needed to select the offset dynamically

Signed-off-by: wenlingyun1 <wenlingyun1@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants