Title: [122341] trunk/Source/_javascript_Core
Revision
122341
Author
[email protected]
Date
2012-07-11 10:50:15 -0700 (Wed, 11 Jul 2012)

Log Message

jsc: Parse options before creating global data
https://bugs.webkit.org/show_bug.cgi?id=90975

Reviewed by Filip Pizlo.

This patch moves the options parsing in "jsc" before the creation
of the JSGlobalData, so that --useJIT=no has a chance to take
effect.

* jsc.cpp:
(CommandLine::parseArguments): Refactor to be a class, and take
argc and argv as constructor arguments.
(jscmain): Move arg parsing before JSGlobalData creation.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (122340 => 122341)


--- trunk/Source/_javascript_Core/ChangeLog	2012-07-11 17:50:03 UTC (rev 122340)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-07-11 17:50:15 UTC (rev 122341)
@@ -1,3 +1,19 @@
+2012-07-11  Andy Wingo  <[email protected]>
+
+        jsc: Parse options before creating global data
+        https://bugs.webkit.org/show_bug.cgi?id=90975
+
+        Reviewed by Filip Pizlo.
+
+        This patch moves the options parsing in "jsc" before the creation
+        of the JSGlobalData, so that --useJIT=no has a chance to take
+        effect.
+
+        * jsc.cpp:
+        (CommandLine::parseArguments): Refactor to be a class, and take
+        argc and argv as constructor arguments.
+        (jscmain): Move arg parsing before JSGlobalData creation.
+
 2012-07-10  Filip Pizlo  <[email protected]>
 
         REGRESSION(r122166): It made 170 tests crash on 32 bit platforms

Modified: trunk/Source/_javascript_Core/jsc.cpp (122340 => 122341)


--- trunk/Source/_javascript_Core/jsc.cpp	2012-07-11 17:50:03 UTC (rev 122340)
+++ trunk/Source/_javascript_Core/jsc.cpp	2012-07-11 17:50:15 UTC (rev 122341)
@@ -113,19 +113,23 @@
     }
 };
 
-struct CommandLine {
-    CommandLine()
-        : interactive(false)
-        , dump(false)
-        , exitCode(false)
+class CommandLine {
+public:
+    CommandLine(int argc, char** argv)
+        : m_interactive(false)
+        , m_dump(false)
+        , m_exitCode(false)
     {
+        parseArguments(argc, argv);
     }
 
-    bool interactive;
-    bool dump;
-    bool exitCode;
-    Vector<Script> scripts;
-    Vector<UString> arguments;
+    bool m_interactive;
+    bool m_dump;
+    bool m_exitCode;
+    Vector<Script> m_scripts;
+    Vector<UString> m_arguments;
+
+    void parseArguments(int, char**);
 };
 
 static const char interactivePrompt[] = "> ";
@@ -623,7 +627,7 @@
     exit(help ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
-static void parseArguments(int argc, char** argv, CommandLine& options)
+void CommandLine::parseArguments(int argc, char** argv)
 {
     int i = 1;
     bool needToDumpOptions = false;
@@ -634,21 +638,21 @@
         if (!strcmp(arg, "-f")) {
             if (++i == argc)
                 printUsageStatement();
-            options.scripts.append(Script(true, argv[i]));
+            m_scripts.append(Script(true, argv[i]));
             continue;
         }
         if (!strcmp(arg, "-e")) {
             if (++i == argc)
                 printUsageStatement();
-            options.scripts.append(Script(false, argv[i]));
+            m_scripts.append(Script(false, argv[i]));
             continue;
         }
         if (!strcmp(arg, "-i")) {
-            options.interactive = true;
+            m_interactive = true;
             continue;
         }
         if (!strcmp(arg, "-d")) {
-            options.dump = true;
+            m_dump = true;
             continue;
         }
         if (!strcmp(arg, "-s")) {
@@ -661,7 +665,7 @@
             continue;
         }
         if (!strcmp(arg, "-x")) {
-            options.exitCode = true;
+            m_exitCode = true;
             continue;
         }
         if (!strcmp(arg, "--")) {
@@ -690,14 +694,14 @@
 
         // This arg is not recognized by the VM nor by jsc. Pass it on to the
         // script.
-        options.scripts.append(Script(true, argv[i]));
+        m_scripts.append(Script(true, argv[i]));
     }
 
-    if (options.scripts.isEmpty())
-        options.interactive = true;
+    if (m_scripts.isEmpty())
+        m_interactive = true;
 
     for (; i < argc; ++i)
-        options.arguments.append(argv[i]);
+        m_arguments.append(argv[i]);
 
     if (needToDumpOptions)
         JSC::Options::dumpAllOptions(stderr);
@@ -707,21 +711,21 @@
 
 int jscmain(int argc, char** argv)
 {
+    // Note that the options parsing can affect JSGlobalData creation, and thus
+    // comes first.
+    CommandLine options(argc, argv);
     RefPtr<JSGlobalData> globalData = JSGlobalData::create(ThreadStackTypeLarge, LargeHeap);
     JSLockHolder lock(globalData.get());
     int result;
 
-    CommandLine options;
-    parseArguments(argc, argv, options);
-
-    GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.arguments);
-    bool success = runWithScripts(globalObject, options.scripts, options.dump);
-    if (options.interactive && success)
+    GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.m_arguments);
+    bool success = runWithScripts(globalObject, options.m_scripts, options.m_dump);
+    if (options.m_interactive && success)
         runInteractive(globalObject);
 
     result = success ? 0 : 3;
 
-    if (options.exitCode)
+    if (options.m_exitCode)
         printf("jsc exiting %d\n", result);
 
     return result;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to