Title: [184354] trunk/Source/_javascript_Core
Revision
184354
Author
basile_clem...@apple.com
Date
2015-05-14 14:32:05 -0700 (Thu, 14 May 2015)

Log Message

Enforce options coherency
https://bugs.webkit.org/show_bug.cgi?id=144921

Reviewed by Mark Lam.

_javascript_Core should be failing early when the options are set in such
a way that we don't have a meaningful way to execute _javascript_, rather
than failing for obscure reasons at some point during execution.

This patch adds a new function that checks whether the options are set
in a coherent way, and makes JSC::Options::initialize() crash when the
environment enforces incoherent options.
Client applications able to add or change additional options are
responsible to check for coherency again before starting to actually
execute _javascript_, if any additional options have been set. This is
implemented for the jsc executable in this patch.

* jsc.cpp:
(CommandLine::parseArguments):
* runtime/Options.cpp:
(JSC::Options::initialize):
(JSC::Options::ensureOptionsAreCoherent): Added.
* runtime/Options.h:
(JSC::Options::ensureOptionsAreCoherent): Added.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (184353 => 184354)


--- trunk/Source/_javascript_Core/ChangeLog	2015-05-14 21:28:54 UTC (rev 184353)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-05-14 21:32:05 UTC (rev 184354)
@@ -1,3 +1,30 @@
+2015-05-12  Basile Clement  <basile_clem...@apple.com>
+
+        Enforce options coherency
+        https://bugs.webkit.org/show_bug.cgi?id=144921
+
+        Reviewed by Mark Lam.
+
+        _javascript_Core should be failing early when the options are set in such
+        a way that we don't have a meaningful way to execute _javascript_, rather
+        than failing for obscure reasons at some point during execution.
+
+        This patch adds a new function that checks whether the options are set
+        in a coherent way, and makes JSC::Options::initialize() crash when the
+        environment enforces incoherent options.
+        Client applications able to add or change additional options are
+        responsible to check for coherency again before starting to actually
+        execute _javascript_, if any additional options have been set. This is
+        implemented for the jsc executable in this patch.
+
+        * jsc.cpp:
+        (CommandLine::parseArguments):
+        * runtime/Options.cpp:
+        (JSC::Options::initialize):
+        (JSC::Options::ensureOptionsAreCoherent): Added.
+        * runtime/Options.h:
+        (JSC::Options::ensureOptionsAreCoherent): Added.
+
 2015-05-14  Yusuke Suzuki  <utatane....@gmail.com>
 
         REGRESSION (r184337): [EFL] unresolved reference errors in ARM builds

Modified: trunk/Source/_javascript_Core/jsc.cpp (184353 => 184354)


--- trunk/Source/_javascript_Core/jsc.cpp	2015-05-14 21:28:54 UTC (rev 184353)
+++ trunk/Source/_javascript_Core/jsc.cpp	2015-05-14 21:32:05 UTC (rev 184354)
@@ -1485,6 +1485,7 @@
 
     if (needToDumpOptions)
         JSC::Options::dumpAllOptions(JSC::Options::DumpLevel::Verbose, "All JSC runtime options:", stderr);
+    JSC::Options::ensureOptionsAreCoherent();
     if (needToExit)
         jscExit(EXIT_SUCCESS);
 }

Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (184353 => 184354)


--- trunk/Source/_javascript_Core/runtime/Options.cpp	2015-05-14 21:28:54 UTC (rev 184353)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp	2015-05-14 21:32:05 UTC (rev 184354)
@@ -370,6 +370,8 @@
         }
         dumpAllOptions(level, title);
     }
+
+    ensureOptionsAreCoherent();
 }
 
 // Parses a single command line option in the format "<optionName>=<value>"
@@ -440,6 +442,17 @@
     fprintf(stream, "%s", footer);
 }
 
+void Options::ensureOptionsAreCoherent()
+{
+    bool coherent = true;
+    if (!(useLLInt() || useJIT())) {
+        coherent = false;
+        dataLog("INCOHERENT OPTIONS: at least one of useLLInt or useJIT must be true\n");
+    }
+    if (!coherent)
+        CRASH();
+}
+
 void Option::dump(FILE* stream) const
 {
     switch (type()) {

Modified: trunk/Source/_javascript_Core/runtime/Options.h (184353 => 184354)


--- trunk/Source/_javascript_Core/runtime/Options.h	2015-05-14 21:28:54 UTC (rev 184353)
+++ trunk/Source/_javascript_Core/runtime/Options.h	2015-05-14 21:32:05 UTC (rev 184354)
@@ -351,6 +351,7 @@
     JS_EXPORT_PRIVATE static bool setOption(const char* arg);
     JS_EXPORT_PRIVATE static void dumpAllOptions(DumpLevel, const char* title = nullptr, FILE* stream = stdout);
     static void dumpOption(DumpLevel, OptionID, FILE* stream = stdout, const char* header = "", const char* footer = "");
+    JS_EXPORT_PRIVATE static void ensureOptionsAreCoherent();
 
     // Declare accessors for each option:
 #define FOR_EACH_OPTION(type_, name_, defaultValue_, description_) \
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to