Title: [188887] trunk/Source/_javascript_Core
- Revision
- 188887
- Author
- [email protected]
- Date
- 2015-08-24 14:51:26 -0700 (Mon, 24 Aug 2015)
Log Message
Add support for setting JSC options from a file.
https://bugs.webkit.org/show_bug.cgi?id=148394
Reviewed by Saam Barati.
This is needed for environments where the JSC executable does not have access to
environmental variables. This is only needed for debugging, and is currently
guarded under a #define USE_OPTIONS_FILE in Options.cpp, and is disabled by
default.
Also fixed Options::setOptions() to be allow for whitespace that is not a single
' '. This makes setOptions() much more flexible and friendlier to use for loading
options in general.
For example, this current use case of loading options from a file may have '\n's
in the character stream, and this feature is easier to implement if setOptions()
just support more than 1 whitespace char between options, and recognize whitespace
characters other than ' '.
* runtime/Options.cpp:
(JSC::parse):
(JSC::Options::initialize):
(JSC::Options::setOptions):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (188886 => 188887)
--- trunk/Source/_javascript_Core/ChangeLog 2015-08-24 21:44:39 UTC (rev 188886)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-08-24 21:51:26 UTC (rev 188887)
@@ -1,3 +1,29 @@
+2015-08-24 Mark Lam <[email protected]>
+
+ Add support for setting JSC options from a file.
+ https://bugs.webkit.org/show_bug.cgi?id=148394
+
+ Reviewed by Saam Barati.
+
+ This is needed for environments where the JSC executable does not have access to
+ environmental variables. This is only needed for debugging, and is currently
+ guarded under a #define USE_OPTIONS_FILE in Options.cpp, and is disabled by
+ default.
+
+ Also fixed Options::setOptions() to be allow for whitespace that is not a single
+ ' '. This makes setOptions() much more flexible and friendlier to use for loading
+ options in general.
+
+ For example, this current use case of loading options from a file may have '\n's
+ in the character stream, and this feature is easier to implement if setOptions()
+ just support more than 1 whitespace char between options, and recognize whitespace
+ characters other than ' '.
+
+ * runtime/Options.cpp:
+ (JSC::parse):
+ (JSC::Options::initialize):
+ (JSC::Options::setOptions):
+
2015-08-24 Filip Pizlo <[email protected]>
DFG::FixupPhase should use the lambda form of m_graph.doToChildren() rather than the old macro
Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (188886 => 188887)
--- trunk/Source/_javascript_Core/runtime/Options.cpp 2015-08-24 21:44:39 UTC (rev 188886)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp 2015-08-24 21:51:26 UTC (rev 188887)
@@ -33,6 +33,7 @@
#include <mutex>
#include <stdlib.h>
#include <string.h>
+#include <wtf/ASCIICType.h>
#include <wtf/DataLog.h>
#include <wtf/NumberOfCores.h>
#include <wtf/PageBlock.h>
@@ -48,6 +49,9 @@
#include "MacroAssemblerX86.h"
#endif
+#define USE_OPTIONS_FILE 0
+#define OPTIONS_FILENAME "/tmp/jsc.options"
+
namespace JSC {
static bool parse(const char* string, bool& value)
@@ -362,6 +366,31 @@
recomputeDependentOptions();
+#if USE(OPTIONS_FILE)
+ {
+ const char* filename = OPTIONS_FILENAME;
+ FILE* optionsFile = fopen(filename, "r");
+ if (!optionsFile) {
+ dataLogF("Failed to open file %s. Did you add the file-read-data entitlement to WebProcess.sb?\n", filename);
+ return;
+ }
+
+ StringBuilder builder;
+ char* line;
+ char buffer[BUFSIZ];
+ while ((line = fgets(buffer, sizeof(buffer), optionsFile)))
+ builder.append(buffer);
+
+ const char* optionsStr = builder.toString().utf8().data();
+ dataLogF("Setting options: %s\n", optionsStr);
+ setOptions(optionsStr);
+
+ int result = fclose(optionsFile);
+ if (result)
+ dataLogF("Failed to close file %s: %s\n", filename, strerror(errno));
+ }
+#endif
+
// Do range checks where needed and make corrections to the options:
ASSERT(Options::thresholdForOptimizeAfterLongWarmUp() >= Options::thresholdForOptimizeAfterWarmUp());
ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= Options::thresholdForOptimizeSoon());
@@ -410,6 +439,12 @@
char* p = optionsStrCopy;
while (p < end) {
+ // Skip white space.
+ while (p < end && isASCIISpace(*p))
+ p++;
+ if (p == end)
+ break;
+
char* optionStart = p;
p = strstr(p, "=");
if (!p) {
@@ -430,7 +465,9 @@
hasStringValue = true;
}
- p = strstr(p, " ");
+ // Find next white space.
+ while (p < end && !isASCIISpace(*p))
+ p++;
if (!p)
p = end; // No more " " separator. Hence, this is the last arg.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes