Bytecode dump/load

The API calls duk_dump_function() and duk_load_function() allow calling C code to (1) serialize an ECMAScript function into a portable bytecode and then (2) load the bytecode to reconstitute the function.

The bytecode format is Duktape version specific and it's unsafe to load bytecode from a different Duktape minor version (patch version doesn't affect bytecode compatibility). Duktape configuration options may also affect bytecode compatibility, so dump/load source and target must be compiled with the same options. The bytecode format is platform neutral so that you can compile bytecode on one platform and then load it on another, which is useful for cross-platform builds. Duktape does not validate loaded bytecode so calling code must ensure bytecode is intact and valid for the running Duktape version.

Calling code must ensure that bytecode being loaded is intact and valid for the running Duktape version (i.e. it has been compiled with the same version of Duktape and hasn't been modified since). Loading invalid bytecode may lead to memory unsafe behavior; loading maliciously crafted bytecode may even lead to exploitable vulnerabilities.

See bytecode.rst for more details.