The mark-serial is a generation number to optimize dependency tracking. It did not actually get
applied correctly, meaning that in rare cases we could miss dependencies. This patch removes the
incorrect serial propagation and ensures that we don't double-count a dependent plugin.
Additionally, this patch ensures that all callers of BindNativeToPlugin() will update the mark
serial, as is required to correctly track dependencies.
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.
This removes one the last remnants of the SourceMod 1.0 VM implementation.
The new parser introduces a number of design changes in the VM. First, the VM now takes greater responsibility for validating and sanity checking the structure of the SMX container format. Previously, malformed SMX files could easily crash SourcePawn. The loader now rejects files that have out-of-bounds offsets or incomplete sections. Complex sections, like debug info or the code stream, are verified lazily.
Internally, the sp_plugin_t structure has been removed. It has been replaced by a new LegacyImage class, designed to be independent from the SPVM API. This potentially lets us load code streams from non-.smx containers. More importantly, it removes a lot of bookkeeping and pre-computed state from PluginRuntime. The LegacyImage class is now responsible for handling debug info as well.
PluginRuntime is now intended to hold only cached or immutable data, and PluginContext holds all VM state. As such PluginContext is now responsible for allocating a plugin's runtime memory, not PluginRuntime.
Finally, some aspects of the loading process have been cleaned up. The
decompression and image handoff logic should now be easier to
understand.
Change the meaning of Plugin_Failed status to indicate, that the plugin
can't recover from the error.
Make sure those previously loaded plugins are shown correctly in sm
plugins info x.
When a plugin calls SetFailState it is paused and all natives it
registered are unavailable. Other plugins, which depend on those natives
keep running and error whenever they try to call those natives.
This correctly sets the dependent plugins to an error state as if the
plugin which called SetFailState was unloaded.
commit c1b064c9232553045f6f5bfaf7df0feb6ceb4571
Author: Peace-Maker <peace-maker@wcfan.de>
Date: Wed May 28 03:16:22 2014 +0200
Coding style adjustments
commit 37a16dbba24cc2035fb8838be8729067cb9bc13a
Author: Peace-Maker <peace-maker@wcfan.de>
Date: Wed May 28 03:03:25 2014 +0200
Load core.phrases before calling OnLibraryAdded
commit 676ac951111c7e8f565debbd4316850a4c4a8d00
Author: Peace-Maker <peace-maker@wcfan.de>
Date: Tue May 27 13:18:48 2014 +0200
Call OnLibraryAdded for all available librarys (bug 5925)
When loading multiple plugins at once (on server start or mapchange)
OnLibraryAdded is only called for libraries which are loaded after the
current plugin. The plugin isn't informed about the libraries that were
added before its OnPluginStart forward was called.
This patch calls OnLibraryAdded for all already registered libraries the
current plugin has missed.
commit c1b064c9232553045f6f5bfaf7df0feb6ceb4571
Author: Peace-Maker <peace-maker@wcfan.de>
Date: Wed May 28 03:16:22 2014 +0200
Coding style adjustments
commit 37a16dbba24cc2035fb8838be8729067cb9bc13a
Author: Peace-Maker <peace-maker@wcfan.de>
Date: Wed May 28 03:03:25 2014 +0200
Load core.phrases before calling OnLibraryAdded
commit 676ac951111c7e8f565debbd4316850a4c4a8d00
Author: Peace-Maker <peace-maker@wcfan.de>
Date: Tue May 27 13:18:48 2014 +0200
Call OnLibraryAdded for all available librarys (bug 5925)
When loading multiple plugins at once (on server start or mapchange)
OnLibraryAdded is only called for libraries which are loaded after the
current plugin. The plugin isn't informed about the libraries that were
added before its OnPluginStart forward was called.
This patch calls OnLibraryAdded for all already registered libraries the
current plugin has missed.