Changeset 253015 in webkit


Ignore:
Timestamp:
Dec 2, 2019 4:20:49 PM (4 years ago)
Author:
mark.lam@apple.com
Message:

Only check each use...FuzzerAgent() option in VM constructor if any of the options are enabled.
https://bugs.webkit.org/show_bug.cgi?id=204763

Reviewed by Keith Miller.

We know that we'll never use fuzzer agents in deployment. Hence, we shouldn't
spend time checking for them in the normal use case. This probably doesn't matter
much for Web processes, but for clients of JSC that repeatedly spawn and kill VMs,
it might matter more. We might want to eventually widen this idiom to include
other debugging / development options, but for now, I'm only covering the fuzzer
agent options.

  • runtime/Options.cpp:

(JSC::computeIfUsingFuzzerAgent):
(JSC::Options::initialize):

  • runtime/Options.h:

(JSC::Options::isUsingFuzzerAgent):

  • runtime/OptionsList.h:

(JSC::OptionRange::operator bool const):

  • runtime/VM.cpp:

(JSC::VM::VM):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r253010 r253015  
     12019-12-02  Mark Lam  <mark.lam@apple.com>
     2
     3        Only check each use...FuzzerAgent() option in VM constructor if any of the options are enabled.
     4        https://bugs.webkit.org/show_bug.cgi?id=204763
     5
     6        Reviewed by Keith Miller.
     7
     8        We know that we'll never use fuzzer agents in deployment.  Hence, we shouldn't
     9        spend time checking for them in the normal use case.  This probably doesn't matter
     10        much for Web processes, but for clients of JSC that repeatedly spawn and kill VMs,
     11        it might matter more.  We might want to eventually widen this idiom to include
     12        other debugging / development options, but for now, I'm only covering the fuzzer
     13        agent options.
     14
     15        * runtime/Options.cpp:
     16        (JSC::computeIfUsingFuzzerAgent):
     17        (JSC::Options::initialize):
     18        * runtime/Options.h:
     19        (JSC::Options::isUsingFuzzerAgent):
     20        * runtime/OptionsList.h:
     21        (JSC::OptionRange::operator bool const):
     22        * runtime/VM.cpp:
     23        (JSC::VM::VM):
     24
    1252019-12-02  Tadeu Zagallo  <tzagallo@apple.com>
    226
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r252978 r253015  
    537537}
    538538
     539static void computeIfUsingFuzzerAgent()
     540{
     541    g_jscConfig.options.isUsingFuzzerAgent = false;
     542#define CHECK_IF_USING_FUZZER_AGENT(type_, name_, defaultValue_, availability_, description_) { \
     543        const char name[] = #name_; \
     544        unsigned nameLength = strlen(name); \
     545        if (nameLength > 14 && !strncmp(name, "use", 3) && !strncmp(&name[nameLength -11], "FuzzerAgent", 11)) { \
     546            if (Options::name_()) \
     547                g_jscConfig.options.isUsingFuzzerAgent = true; \
     548        } \
     549    }
     550    FOR_EACH_JSC_OPTION(CHECK_IF_USING_FUZZER_AGENT)
     551#undef CHECK_IF_USING_FUZZER_AGENT
     552}
     553
    539554void Options::initialize()
    540555{
     
    610625            dumpOptionsIfNeeded();
    611626            ensureOptionsAreCoherent();
     627            computeIfUsingFuzzerAgent();
    612628
    613629#if HAVE(MACH_EXCEPTIONS)
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r252557 r253015  
    9898    static bool isAvailable(ID, Availability);
    9999
     100    static bool isUsingFuzzerAgent() { return g_jscConfig.options.isUsingFuzzerAgent; }
     101
    100102private:
    101103    struct ConstMetaData {
  • trunk/Source/JavaScriptCore/runtime/OptionsList.h

    r252978 r253015  
    573573    const char* rangeString() const { return (m_state > InitError) ? m_rangeString : s_nullRangeStr; }
    574574   
     575    operator bool() const { return m_state != Uninitialized; }
     576
    575577    void dump(PrintStream& out) const;
    576578
     
    599601FOR_EACH_JSC_OPTION(DECLARE_OPTION)
    600602#undef DECLARE_OPTION
     603
     604    bool isUsingFuzzerAgent; // This value is computed in Options::initialize().
    601605};
    602606
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r253007 r253015  
    463463#endif // ENABLE(SAMPLING_PROFILER)
    464464
    465     if (Options::useRandomizingFuzzerAgent())
    466         setFuzzerAgent(makeUnique<RandomizingFuzzerAgent>(*this));
    467     if (Options::useDoublePredictionFuzzerAgent())
    468         setFuzzerAgent(makeUnique<DoublePredictionFuzzerAgent>(*this));
    469     if (Options::useFileBasedFuzzerAgent())
    470         setFuzzerAgent(makeUnique<FileBasedFuzzerAgent>(*this));
    471     if (Options::usePredictionFileCreatingFuzzerAgent())
    472         setFuzzerAgent(makeUnique<PredictionFileCreatingFuzzerAgent>(*this));
     465    if (UNLIKELY(Options::isUsingFuzzerAgent())) {
     466        if (Options::useRandomizingFuzzerAgent())
     467            setFuzzerAgent(makeUnique<RandomizingFuzzerAgent>(*this));
     468        if (Options::useDoublePredictionFuzzerAgent())
     469            setFuzzerAgent(makeUnique<DoublePredictionFuzzerAgent>(*this));
     470        if (Options::useFileBasedFuzzerAgent())
     471            setFuzzerAgent(makeUnique<FileBasedFuzzerAgent>(*this));
     472        if (Options::usePredictionFileCreatingFuzzerAgent())
     473            setFuzzerAgent(makeUnique<PredictionFileCreatingFuzzerAgent>(*this));
     474    }
    473475
    474476    if (Options::alwaysGeneratePCToCodeOriginMap())
Note: See TracChangeset for help on using the changeset viewer.