⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243885 in webkit


Ignore:
Timestamp:
Apr 4, 2019, 11:53:08 AM (7 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Pass CodeOrigin to FuzzerAgent
https://bugs.webkit.org/show_bug.cgi?id=196590

Reviewed by Saam Barati.

Pass CodeOrigin instead of bytecodeIndex. CodeOrigin includes richer information (InlineCallFrame*).
We also mask prediction with SpecBytecodeTop in DFGByteCodeParser. The fuzzer can produce any SpeculatedTypes,
but DFGByteCodeParser should only see predictions that can be actually produced from the bytecode execution.

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::getPredictionWithoutOSRExit):

  • runtime/FuzzerAgent.cpp:

(JSC::FuzzerAgent::getPrediction):

  • runtime/FuzzerAgent.h:
  • runtime/RandomizingFuzzerAgent.cpp:

(JSC::RandomizingFuzzerAgent::getPrediction):

  • runtime/RandomizingFuzzerAgent.h:
Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r243875 r243885  
     12019-04-04  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Pass CodeOrigin to FuzzerAgent
     4        https://bugs.webkit.org/show_bug.cgi?id=196590
     5
     6        Reviewed by Saam Barati.
     7
     8        Pass CodeOrigin instead of bytecodeIndex. CodeOrigin includes richer information (InlineCallFrame*).
     9        We also mask prediction with SpecBytecodeTop in DFGByteCodeParser. The fuzzer can produce any SpeculatedTypes,
     10        but DFGByteCodeParser should only see predictions that can be actually produced from the bytecode execution.
     11
     12        * dfg/DFGByteCodeParser.cpp:
     13        (JSC::DFG::ByteCodeParser::getPredictionWithoutOSRExit):
     14        * runtime/FuzzerAgent.cpp:
     15        (JSC::FuzzerAgent::getPrediction):
     16        * runtime/FuzzerAgent.h:
     17        * runtime/RandomizingFuzzerAgent.cpp:
     18        (JSC::RandomizingFuzzerAgent::getPrediction):
     19        * runtime/RandomizingFuzzerAgent.h:
     20
    1212019-04-04  Caio Lima  <ticaiolima@gmail.com>
    222
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r243832 r243885  
    833833    SpeculatedType getPredictionWithoutOSRExit(unsigned bytecodeIndex)
    834834    {
    835         auto getValueProfilePredictionFromForCodeBlockAndBytecodeOffset = [&] (CodeBlock* codeBlock, int bytecodeIndex)
     835        auto getValueProfilePredictionFromForCodeBlockAndBytecodeOffset = [&] (CodeBlock* codeBlock, const CodeOrigin& codeOrigin)
    836836        {
    837837            SpeculatedType prediction;
    838838            {
    839839                ConcurrentJSLocker locker(codeBlock->m_lock);
    840                 prediction = codeBlock->valueProfilePredictionForBytecodeOffset(locker, bytecodeIndex);
     840                prediction = codeBlock->valueProfilePredictionForBytecodeOffset(locker, codeOrigin.bytecodeIndex());
    841841            }
    842842            auto* fuzzerAgent = m_vm->fuzzerAgent();
    843843            if (UNLIKELY(fuzzerAgent))
    844                 return fuzzerAgent->getPrediction(codeBlock, bytecodeIndex, prediction);
     844                return fuzzerAgent->getPrediction(codeBlock, codeOrigin, prediction) & SpecBytecodeTop;
    845845            return prediction;
    846846        };
    847847
    848         SpeculatedType prediction = getValueProfilePredictionFromForCodeBlockAndBytecodeOffset(m_inlineStackTop->m_profiledBlock, bytecodeIndex);
     848        SpeculatedType prediction = getValueProfilePredictionFromForCodeBlockAndBytecodeOffset(m_inlineStackTop->m_profiledBlock, CodeOrigin(bytecodeIndex, inlineCallFrame()));
    849849        if (prediction != SpecNone)
    850850            return prediction;
     
    880880                stack = stack->m_caller;
    881881
    882             return getValueProfilePredictionFromForCodeBlockAndBytecodeOffset(stack->m_profiledBlock, codeOrigin->bytecodeIndex());
     882            return getValueProfilePredictionFromForCodeBlockAndBytecodeOffset(stack->m_profiledBlock, *codeOrigin);
    883883        }
    884884
  • trunk/Source/JavaScriptCore/runtime/FuzzerAgent.cpp

    r243832 r243885  
    3333}
    3434
    35 SpeculatedType FuzzerAgent::getPrediction(CodeBlock*, int, SpeculatedType result)
     35SpeculatedType FuzzerAgent::getPrediction(CodeBlock*, const CodeOrigin&, SpeculatedType result)
    3636{
    3737    return result;
  • trunk/Source/JavaScriptCore/runtime/FuzzerAgent.h

    r243832 r243885  
    2626#pragma once
    2727
     28#include "CodeOrigin.h"
    2829#include "SpeculatedType.h"
    29 #include <wtf/Locker.h>
    3030
    3131namespace JSC {
     
    3737    JS_EXPORT_PRIVATE virtual ~FuzzerAgent();
    3838
    39     JS_EXPORT_PRIVATE virtual SpeculatedType getPrediction(CodeBlock*, int bytecodeOffset, SpeculatedType);
     39    JS_EXPORT_PRIVATE virtual SpeculatedType getPrediction(CodeBlock*, const CodeOrigin&, SpeculatedType);
    4040};
    4141
  • trunk/Source/JavaScriptCore/runtime/RandomizingFuzzerAgent.cpp

    r243857 r243885  
    2828
    2929#include "CodeBlock.h"
     30#include <wtf/Locker.h>
    3031
    3132namespace JSC {
     
    3637}
    3738
    38 SpeculatedType RandomizingFuzzerAgent::getPrediction(CodeBlock* codeBlock, int bytecodeIndex, SpeculatedType original)
     39SpeculatedType RandomizingFuzzerAgent::getPrediction(CodeBlock* codeBlock, const CodeOrigin& codeOrigin, SpeculatedType original)
    3940{
    4041    auto locker = holdLock(m_lock);
     
    4344    SpeculatedType generated = static_cast<SpeculatedType>((static_cast<uint64_t>(high) << 32) | low) & SpecFullTop;
    4445    if (Options::dumpRandomizingFuzzerAgentPredictions())
    45         dataLogLn("getPrediction name:(", codeBlock->inferredName(), "#", codeBlock->hashAsStringIfPossible(), "),bytecodeIndex:(", bytecodeIndex, "),original:(", SpeculationDump(original), "),generated:(", SpeculationDump(generated), ")");
     46        dataLogLn("getPrediction name:(", codeBlock->inferredName(), "#", codeBlock->hashAsStringIfPossible(), "),bytecodeIndex:(", codeOrigin.bytecodeIndex(), "),original:(", SpeculationDump(original), "),generated:(", SpeculationDump(generated), ")");
    4647    return generated;
    4748}
  • trunk/Source/JavaScriptCore/runtime/RandomizingFuzzerAgent.h

    r243832 r243885  
    3838    RandomizingFuzzerAgent(VM&);
    3939
    40     SpeculatedType getPrediction(CodeBlock*, int bytecodeOffset, SpeculatedType) override;
     40    SpeculatedType getPrediction(CodeBlock*, const CodeOrigin&, SpeculatedType) override;
    4141
    4242private:
Note: See TracChangeset for help on using the changeset viewer.