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

Disable script interpreter safe checks for regular build #843

Closed
ghost opened this issue Jun 19, 2019 · 0 comments · Fixed by #1990
Closed

Disable script interpreter safe checks for regular build #843

ghost opened this issue Jun 19, 2019 · 0 comments · Fixed by #1990
Labels
context: performance related to improving program speed or lowering system requirements context: script vm res: in consideration type: enhancement a suggestion or necessity to have something improved

Comments

@ghost
Copy link

ghost commented Jun 19, 2019

As noted in previous discussion (#815) the checks in script interpreter may produce overhead, which is not good especially since it's not very fast and optimal in general.

The suggestion was to replace the checks with an assert-like function that definition depends on compilation flags. Quoting parts of the discussion:

Still I would like to have some kind of "assert" function there that would trigger a break point automatically under debugger. Mere warning message may not be convenient because when debugging it may be essential to stop at exact moment something unexpected happen to observe the issue.

Perhaps there could be a function like "script_assert" which definition depends on compiler flags. It could be a no-op for release build, a warning output for regular debug build and an actual assert if we have e.g. DEBUG_SCRIPT_VM flag defined.

PS. maybe not literally "assert" though, since its implementation may abort the program afterwards, but something else that works as a break point.

the only portable way to do this is to emit SIGTRAP signal, but that's only for POSIX compatible platforms. for windows, if x86 cpu is used, one can use asm("int3");. both of them will cause the program to abort if there's no debugger attached though. so one could make it dependant on whether a debugger is attached, which on POSIX can be found out via ptrace with PTRACE_TRACEME, iirc. but i don't know for windows.

@ivan-mogilko ivan-mogilko added the type: enhancement a suggestion or necessity to have something improved label Oct 24, 2019
@ivan-mogilko ivan-mogilko added the context: performance related to improving program speed or lowering system requirements label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: performance related to improving program speed or lowering system requirements context: script vm res: in consideration type: enhancement a suggestion or necessity to have something improved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant