Commit Graph

10 Commits

Author SHA1 Message Date
David Anderson
a1afa23bc4 Implement a new stack and error handling model for the SourcePawn VM.
This has three major changes to SourcePawn. First, the API now supports the concept of "exceptions". The exception state is a global property of an instance of the SourcePawn VM. Exceptions can be caught or suppressed. Many places in SourceMod have been updated to check exceptions instead of errors.

The new API obsoletes major parts of the embedder API - all but one method of invoking functions is obsoleted, and the debug interface has been scrapped. Extensions using the native API will not be affected, however, ThrowNativeError has been deprecated in favor of ReportError.

Second, the SourcePawn concept of a "stack" has been unified at the API level. A stack frame iterator now iterates over all SourcePawn invocations, rather than the topmost plugin. This makes error handling more consistent and removes another dependency on context-per-plugin.

Finally, the implementation of stack frames has been changed dramatically. Rather than maintain a complicated and expensive return pointer stack, we now rely on the implicit one provided by the CPU. The stack frame iterator now walks the JIT stack directly. This removes many unnecessary bookkeeping instructions from the generated code, in particular making the CALL instruction 40% faster.

These changes required some fair surgery to the JIT. Its error paths are now slightly more complicated, as they have to throw an exception rather than return an error code. In addition, any path that can throw an exception is now responsible for creating an "exit frame", which exists to tell the stack frame iterator about transitions from the JIT to the VM.
2015-03-04 23:45:30 -08:00
David Anderson
b2c61a341a Move sp from sp_context_t to PluginContext. 2015-02-24 21:54:30 -08:00
David Anderson
d2005bd42a Move cip from sp_context_t to PluginContext. 2015-02-24 20:53:44 -08:00
dvander@alliedmods.net
8b8edf6e70 Remove dead file and fix gcc build. 2015-02-24 11:39:28 -08:00
David Anderson
111dd7eb68 Factor code stubs out of JITX86. 2015-02-24 02:03:58 -08:00
David Anderson
8c95919b32 Move watchdog/runtime interaction into Environment. 2015-02-24 02:03:55 -08:00
David Anderson
c70e87d582 Move the code cache into Environment, and out of knight/shared. 2015-02-24 01:57:50 -08:00
David Anderson
57ba8fd09b De-singleton-ify the watchdog timer. 2015-02-24 01:53:37 -08:00
David Anderson
3cf3f6c3f8 Merge sp_vm_engine and engine2. 2015-02-24 01:52:14 -08:00
David Anderson
499f7b3929 Refactor the public API entrypoint for SourcePawn. 2015-02-24 01:52:13 -08:00