From edb332ed8705c72dd21274775336e5b5684384a4 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 22 Oct 2012 10:19:49 +0200 Subject: [PATCH] issue #251: added --javascript.v8-options command line argument --- CHANGELOG | 4 +++ .../Documentation/command-line-options.dox | 4 +++ arangod/V8Server/ApplicationV8.cpp | 10 ++++-- arangod/V8Server/ApplicationV8.h | 33 +++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d00f0dbbe0..6301e4a529 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -32,6 +32,10 @@ v1.1.beta1 (2012-XX-XX) - if the length of the HTTP headers is greated than the maximum allowed size (1 MB), the server will fail with HTTP 431 (request header fields too large) +* issue #251: allow passing arbitrary options to V8 engine using new command line option: + --javascript.v8-options. Using this option, the Harmony features or other settings in + v8 can be enabled if the end user requires them + * issue #248: allow AQL optimiser to pull out completely uncorrelated subqueries to the top level, resulting in less repeated evaluation of the subquery diff --git a/arangod/Documentation/command-line-options.dox b/arangod/Documentation/command-line-options.dox index 321d094d27..53e70dc731 100644 --- a/arangod/Documentation/command-line-options.dox +++ b/arangod/Documentation/command-line-options.dox @@ -61,6 +61,7 @@ ///
  • @ref CommandLineArangoRemoveOnDrop "database.remove-on-compacted"
  • ///
  • @ref CommandLineArangoJsGcFrequency "javascript.gc-frequency"
  • ///
  • @ref CommandLineArangoJsGcInterval "javascript.gc-interval"
  • +///
  • @ref CommandLineArangoJsV8Options "javascript.v8-options"
  • /// /// ///
  • @ref CommandLineLogging @@ -222,6 +223,9 @@ /// @anchor CommandLineArangoJsGcInterval /// @copydetails triagens::arango::ApplicationV8::_gcInterval /// +/// @anchor CommandLineArangoJsV8Options +/// @copydetails triagens::arango::ApplicationV8::_v8Options; +/// /// @section CommandLineScheduler Command-Line Options for Communication //////////////////////////////////////////////////////////////////////// /// diff --git a/arangod/V8Server/ApplicationV8.cpp b/arangod/V8Server/ApplicationV8.cpp index 532fdbed2a..6d6c6ad58b 100644 --- a/arangod/V8Server/ApplicationV8.cpp +++ b/arangod/V8Server/ApplicationV8.cpp @@ -179,6 +179,7 @@ ApplicationV8::ApplicationV8 (string const& binaryPath) _useActions(true), _gcInterval(1000), _gcFrequency(10.0), + _v8Options(""), _startupLoader(), _actionLoader(), _vocbase(0), @@ -485,12 +486,10 @@ void ApplicationV8::setupOptions (map options["JAVASCRIPT Options:help-admin"] ("javascript.gc-interval", &_gcInterval, "JavaScript request-based garbage collection interval (each x requests)") ("javascript.gc-frequency", &_gcFrequency, "JavaScript time-based garbage collection frequency (each x seconds)") - ; - - options["JAVASCRIPT Options:help-admin"] ("javascript.action-directory", &_actionPath, "path to the JavaScript action directory") ("javascript.modules-path", &_startupModules, "one or more directories separated by (semi-) colons") ("javascript.startup-directory", &_startupPath, "path to the directory containing alternate JavaScript startup scripts") + ("javascript.v8-options", &_v8Options, "options to pass to v8") ; } @@ -546,6 +545,11 @@ bool ApplicationV8::prepare () { } } + if (_v8Options.size() > 0) { + LOGGER_INFO << "using V8 options '" << _v8Options << "'"; + v8::V8::SetFlagsFromString(_v8Options.c_str(), _v8Options.size()); + } + // setup instances _contexts = new V8Context*[_nrInstances]; diff --git a/arangod/V8Server/ApplicationV8.h b/arangod/V8Server/ApplicationV8.h index b184688ff8..5d984f13b8 100644 --- a/arangod/V8Server/ApplicationV8.h +++ b/arangod/V8Server/ApplicationV8.h @@ -385,6 +385,39 @@ namespace triagens { double _gcFrequency; +//////////////////////////////////////////////////////////////////////////////// +/// @brief optional arguments to pass to v8 +/// +/// @CMDOPT{\-\-javascript.v8-options @CA{options}} +/// +/// Optional arguments to pass to the V8 Javascript engine. The V8 engine will +/// run with default settings unless explicit options are specified using this +/// option. The options passed will be forwarded to the V8 engine which will +/// parse them on its own. Passing invalid options may result in an error being +/// printed on stderr and the option being ignored. +/// +/// Options need to be passed in one string, with V8 option names being prefixed +/// with double dashes. Multiple options need to be separated by whitespace. +/// To get a list of all available V8 options, you can use +/// the value @LIT{"--help"} as follows: +/// @code +/// --javascript.v8-options "--help" +/// @endcode +/// +/// Another example of specific V8 options being set at startup: +/// @code +/// --javascript.v8-options "--harmony --log" +/// @endcode +/// +/// Names and features or usable options depend on the version of V8 being used, +/// and might change in the future if a different version of V8 is being used +/// in ArangoDB. Not all options offered by V8 might be sensible to use in the +/// context of ArangoDB. Use the specific options only if you are sure that +/// they are not harmful for the regular database operation. +//////////////////////////////////////////////////////////////////////////////// + + string _v8Options; + //////////////////////////////////////////////////////////////////////////////// /// @brief V8 startup loader ////////////////////////////////////////////////////////////////////////////////