Add ability to configure JSC options from a file
https://bugs.webkit.org/show_bug.cgi?id=168914
Reviewed by Filip Pizlo.
Added the ability to set options and DataLog file location via a configuration file.
Source/JavaScriptCore:
The configuration file is specified with the --configFile option to JSC or the
JSC_configFile environment variable.
The file format allows for options conditionally dependent on various attributes.
Currently those attributes are the process name, parent process name and build
type (Release or Debug). In this patch, the parent process type is not set.
That will be set up in WebKit code with a follow up patch.
Here is an example config file:
logFile = "/tmp/jscLog.%pid.txt"
jscOptions {
dumpOptions = 2
}
build == "Debug" {
jscOptions {
useConcurrentJIT = false
dumpDisassembly = true
}
}
build == "Release" && processName == "jsc" {
jscOptions {
asyncDisassembly = true
}
}
Eliminated the prior options file code.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* jsc.cpp:
(jscmain):
* runtime/ConfigFile.cpp: Added.
(JSC::ConfigFileScanner::ConfigFileScanner):
(JSC::ConfigFileScanner::start):
(JSC::ConfigFileScanner::lineNumber):
(JSC::ConfigFileScanner::currentBuffer):
(JSC::ConfigFileScanner::atFileEnd):
(JSC::ConfigFileScanner::tryConsume):
(JSC::ConfigFileScanner::tryConsumeString):
(JSC::ConfigFileScanner::tryConsumeUpto):
(JSC::ConfigFileScanner::fillBufferIfNeeded):
(JSC::ConfigFileScanner::fillBuffer):
(JSC::ConfigFile::ConfigFile):
(JSC::ConfigFile::setProcessName):
(JSC::ConfigFile::setParentProcessName):
(JSC::ConfigFile::parse):
* runtime/ConfigFile.h: Added.
* runtime/Options.cpp:
(JSC::Options::initialize):
(JSC::Options::setOptions):
* runtime/Options.h:
Source/WTF:
The pathname can include the printf style "%pid", which will be replaced with the
current process id.
* wtf/DataLog.cpp:
(WTF::initializeLogFileOnce):
(WTF::setDataFile):
* wtf/DataLog.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@213151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/runtime/ConfigFile.h b/Source/JavaScriptCore/runtime/ConfigFile.h
new file mode 100644
index 0000000..a8964f4
--- /dev/null
+++ b/Source/JavaScriptCore/runtime/ConfigFile.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace JSC {
+
+class ConfigFile {
+public:
+ JS_EXPORT_PRIVATE ConfigFile(const char*);
+
+ JS_EXPORT_PRIVATE static void setProcessName(const char*);
+ JS_EXPORT_PRIVATE static void setParentProcessName(const char*);
+ JS_EXPORT_PRIVATE void parse();
+
+private:
+ static char s_processName[];
+ static char s_parentProcessName[];
+
+ const char* m_filename;
+};
+
+} // namespace JSC