-
Notifications
You must be signed in to change notification settings - Fork 0
YEngine
This is a fully functional replacement for XEngine for LSL/OSSL scripts, featuring:
- Preemptive Multitasking
- Improved script syntax
- Expressions evaluation order closer to original LSL specification via yoptions
- Memory heap and stack use control per script
- Optional new language extensions
YEngine does direct translation from script language to .net IL code, this makes it compile faster than XEngine. XEngine translates script language to C#, and then uses .net compiler to generate IL, this is naturally slower. While XEngine could compile scripts in other languages like C#, YEngine only supports LSL. Due to security issues, those other languages could not be actually used, except on very special and restricted cases.
Once a script code is loaded on XEngine, the memory used by it can not be recovered whne the script is deleted, unless a .net feature called AppDomains are used But AppDomains are very heavy, use a lot more memory and worse, have a huge negative impact on scripts performance On calls crossing domains ( ie the script and main framework) all parameters and return values are serialized and deserialized by sender and receiver domains.
Yengine loads scripts code in a diferent way, most their memory is recovered on delete without the need for those AppDomains.
YEngine executes script events using preemptive multitasking. This means that, at certain control points or when told, a script may release execution, being placed on a queue waiting for its turn to execute again. The released execution thread goes on processing other scripts.
When a new event started execution, it will be allowed to run for about 60ms (subject to change) until releasing execution. When it is is turn to execute again it will be allowed to run for another 30ms(subject to change). This will be repeated until all the event code is executed Engine will give more priority to short fast events.
The script can also be placed in a sleep state until a sleep time lapses. This, for example, solves one of XEngine worse problems: llSleep() and other internal script sleeps. On YEngine, this just releases execution and waits in a queue, until the sleep time expires. On XEngine an "expensive" execution thread was placed in Sleep mode, so not available to do anything.
YEngine follows more closely the LSL script syntax and execution order. statements like
if(oneKey)
...should now work.
llSomething; // missing()
break; // but see new extensionsare now errors
Complex statements execution order is closer to LSL specification than XEngine execution order.
for example, with i = 1;
((i == 2) && (i++ == 1))will evaluate to true as by LSL spec, while on XEngine it will evaluate to false, because it will do (i == 2) first
Even if not useful in this case, always use parentheses (...) to enforce the order you need (and do this in any language)!
**Scripts using these features will only work on a compatible YEngine version. They will not compile or run on XEngine or older versions of YEngine. **
If the second line of a script is (currently first line needs to be present, empty or with script engine selection)
yoptions;The following Yengine specific language extensions are activated
| Yoption | Description |
|---|---|
| advflowctl | Provides traditional break/continue/switch/case statements |
| arrays | Provides an associative mutable datatype |
| chars | Provides the character datatype |
| include | Read source from another location |
| inline events | Handle event processing inline instead of using event handle |
| norighttoleft | Enables an optimization |
| objects | Provides a mechanism to create script-definable class types, including generics and fixed-dimension arrays |
| trycatch | Provides a mechanism to catch exceptions |
| samples | Example scripts using YEngine features |
| all | Useful if using 4 or more options. Does not support norighttoleft. Enable viayoption all;
|
Notes:
-
Scripts using these features will not compile or run on XEngine.
-
The keywords that are part of the extensions will not be recognized until the corresponding yoption statement has been given, so the new keywords don't interfere with existing scripts.
-
The parts of the yoption statement are case-insensitive.
YEngine keeps control of the memory a script uses. There are two types of memory:
- Stack holds function arguments and simple local variables.
- Heap holds global variables and complex variables like lists or strings, even if they are local to a method/event.
The maximum memory a script can use can be configured in the OpenSim.ini section [YEngine]
[YEngine]
; maximum stack a script can use in KB
;ScriptStackSize = 2048
; maximum heap memory a script can use in KB
;ScriptHeapSize = 1024You may need to increase these values
OpenSimulator default configuration selects XEngine. To change to YEngine you need to change OpenSim.ini: [Startup] section:
DefaultScriptEngine= "YEngine"
[YEngine] section:
Enable = true
[XEngine] section:
Enable = false
Note: in theory, OpenSimulator could run several engines at the same time, but we should not do that with XEngine and YEngine.
#Configuration
Please see file OpenSimDefaults.ini, section [YEngine] for details. As in all case, if you need to change something, copy respective lines to similar location on file OpenSim.ini, and change there
YEngine is a modified derivative of XMREngine. XMREngine was developed by teams of DreamNation and Avination grids, based on early work by Meta7. It is still in use by DreamNation.
http://wiki.dreamnation.net/index.php/XMREngine_Script_Engine
A lot of information about XMREngine no longer applies to YEngine. Some features may still work, but may be removed or changed.