Changeset 122341 in webkit


Ignore:
Timestamp:
Jul 11, 2012 10:50:15 AM (12 years ago)
Author:
wingo@igalia.com
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.

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r122208 r122341  
     12012-07-11  Andy Wingo  <wingo@igalia.com>
     2
     3        jsc: Parse options before creating global data
     4        https://bugs.webkit.org/show_bug.cgi?id=90975
     5
     6        Reviewed by Filip Pizlo.
     7
     8        This patch moves the options parsing in "jsc" before the creation
     9        of the JSGlobalData, so that --useJIT=no has a chance to take
     10        effect.
     11
     12        * jsc.cpp:
     13        (CommandLine::parseArguments): Refactor to be a class, and take
     14        argc and argv as constructor arguments.
     15        (jscmain): Move arg parsing before JSGlobalData creation.
     16
    1172012-07-10  Filip Pizlo  <fpizlo@apple.com>
    218
  • trunk/Source/JavaScriptCore/jsc.cpp

    r121798 r122341  
    114114};
    115115
    116 struct CommandLine {
    117     CommandLine()
    118         : interactive(false)
    119         , dump(false)
    120         , exitCode(false)
     116class CommandLine {
     117public:
     118    CommandLine(int argc, char** argv)
     119        : m_interactive(false)
     120        , m_dump(false)
     121        , m_exitCode(false)
    121122    {
    122     }
    123 
    124     bool interactive;
    125     bool dump;
    126     bool exitCode;
    127     Vector<Script> scripts;
    128     Vector<UString> arguments;
     123        parseArguments(argc, argv);
     124    }
     125
     126    bool m_interactive;
     127    bool m_dump;
     128    bool m_exitCode;
     129    Vector<Script> m_scripts;
     130    Vector<UString> m_arguments;
     131
     132    void parseArguments(int, char**);
    129133};
    130134
     
    624628}
    625629
    626 static void parseArguments(int argc, char** argv, CommandLine& options)
     630void CommandLine::parseArguments(int argc, char** argv)
    627631{
    628632    int i = 1;
     
    635639            if (++i == argc)
    636640                printUsageStatement();
    637             options.scripts.append(Script(true, argv[i]));
     641            m_scripts.append(Script(true, argv[i]));
    638642            continue;
    639643        }
     
    641645            if (++i == argc)
    642646                printUsageStatement();
    643             options.scripts.append(Script(false, argv[i]));
     647            m_scripts.append(Script(false, argv[i]));
    644648            continue;
    645649        }
    646650        if (!strcmp(arg, "-i")) {
    647             options.interactive = true;
     651            m_interactive = true;
    648652            continue;
    649653        }
    650654        if (!strcmp(arg, "-d")) {
    651             options.dump = true;
     655            m_dump = true;
    652656            continue;
    653657        }
     
    662666        }
    663667        if (!strcmp(arg, "-x")) {
    664             options.exitCode = true;
     668            m_exitCode = true;
    665669            continue;
    666670        }
     
    691695        // This arg is not recognized by the VM nor by jsc. Pass it on to the
    692696        // script.
    693         options.scripts.append(Script(true, argv[i]));
    694     }
    695 
    696     if (options.scripts.isEmpty())
    697         options.interactive = true;
     697        m_scripts.append(Script(true, argv[i]));
     698    }
     699
     700    if (m_scripts.isEmpty())
     701        m_interactive = true;
    698702
    699703    for (; i < argc; ++i)
    700         options.arguments.append(argv[i]);
     704        m_arguments.append(argv[i]);
    701705
    702706    if (needToDumpOptions)
     
    708712int jscmain(int argc, char** argv)
    709713{
     714    // Note that the options parsing can affect JSGlobalData creation, and thus
     715    // comes first.
     716    CommandLine options(argc, argv);
    710717    RefPtr<JSGlobalData> globalData = JSGlobalData::create(ThreadStackTypeLarge, LargeHeap);
    711718    JSLockHolder lock(globalData.get());
    712719    int result;
    713720
    714     CommandLine options;
    715     parseArguments(argc, argv, options);
    716 
    717     GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.arguments);
    718     bool success = runWithScripts(globalObject, options.scripts, options.dump);
    719     if (options.interactive && success)
     721    GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.m_arguments);
     722    bool success = runWithScripts(globalObject, options.m_scripts, options.m_dump);
     723    if (options.m_interactive && success)
    720724        runInteractive(globalObject);
    721725
    722726    result = success ? 0 : 3;
    723727
    724     if (options.exitCode)
     728    if (options.m_exitCode)
    725729        printf("jsc exiting %d\n", result);
    726730
Note: See TracChangeset for help on using the changeset viewer.