wasm-c-api icon indicating copy to clipboard operation
wasm-c-api copied to clipboard

A mechanism for flags initialization

Open titzer opened this issue 5 years ago • 1 comments

The API currently has no way to set the underlying engine's command-line arguments. These arguments are useful to enable/disable different performance, debugging and tracing options, such as the tiering strategy, trace output, etc.

The V8 API has the following:

  static void SetFlagsFromCommandLine(int* argc,
                                      char** argv,
                                      bool remove_flags);

While of course being engine-specific, this can still be useful.

titzer avatar Mar 04 '19 14:03 titzer

The intended way for the API to support engine-specific options is through the abstract wasm::Config object passed to the Engine constructor. This object is meant to be an extension hook. For example, a more complete V8 implementation of this library could add a separate header that provides functionality to set proprietary options:

// wasm-v8.hh
namespace wasm {
  namespace v8 {
    namespace Config {
      void set_max_memory_size(wasm::Config&, uint32_t);
      void set_max_table_size(wasm::Config&, uint32_t);
      void set_enable_liftoff(wasm::Config&, bool);
      void set_num_compilation_tasks(wasm::Config&, int);
      void set_write_protect_code_memory(wasm::Config&, bool);
      ...
    };
  };
};

If you want to support passing a string of command-line style options you could also easily add

void set_options_from_command_line(wasm::Config&, int* argc, char** argv);

rossberg avatar Mar 08 '19 10:03 rossberg