Changeset 172949 in webkit


Ignore:
Timestamp:
Aug 25, 2014, 7:17:58 PM (11 years ago)
Author:
[email protected]
Message:

Return statement TypeSet's might be duplicated
https://bugs.webkit.org/show_bug.cgi?id=136200

Patch by Saam Barati <[email protected]> on 2014-08-25
Reviewed by Filip Pizlo.

Currently, the globalTypeSet that converges the types of all
return statements in a function lives off of CodeBlock. It lives
off CodeBlock because of a faulty assumption that CodeBlock
will have a one to one mapping with a function in the source
text of the program. (Currently, there isn't an actual bug
with this design because TypeLocationCache will hash cons to
the same TypeLocation, but this is still an incorrect design).
In this patch, the globalTypeSet for function return statements
is moved to the FunctionExecutable object which does have a one
to one mapping with functions in the source text of a program.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::returnStatementTypeSet): Deleted.

  • runtime/Executable.h:

(JSC::FunctionExecutable::returnStatementTypeSet):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r172940 r172949  
     12014-08-25  Saam Barati  <[email protected]>
     2
     3        Return statement TypeSet's might be duplicated
     4        https://bugs.webkit.org/show_bug.cgi?id=136200
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Currently, the globalTypeSet that converges the types of all
     9        return statements in a function lives off of CodeBlock. It lives
     10        off CodeBlock because of a faulty assumption that CodeBlock
     11        will have a one to one mapping with a function in the source
     12        text of the program. (Currently, there isn't an actual bug
     13        with this design because TypeLocationCache will hash cons to
     14        the same TypeLocation, but this is still an incorrect design).
     15        In this patch, the globalTypeSet for function return statements 
     16        is moved to the FunctionExecutable object which does have a one
     17        to one mapping with functions in the source text of a program.
     18
     19        * bytecode/CodeBlock.cpp:
     20        (JSC::CodeBlock::CodeBlock):
     21        * bytecode/CodeBlock.h:
     22        (JSC::CodeBlock::returnStatementTypeSet): Deleted.
     23        * runtime/Executable.h:
     24        (JSC::FunctionExecutable::returnStatementTypeSet):
     25
    1262014-08-24  Filip Pizlo  <[email protected]>
    227
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r172822 r172949  
    17071707    , m_optimizationDelayCounter(0)
    17081708    , m_reoptimizationRetryCounter(0)
    1709     , m_returnStatementTypeSet(nullptr)
    17101709#if ENABLE(JIT)
    17111710    , m_capabilityLevelState(DFG::CapabilityLevelNotSet)
     
    20442043            }
    20452044            case ProfileTypeBytecodeFunctionReturnStatement: {
    2046                 globalTypeSet = returnStatementTypeSet();
     2045                RELEASE_ASSERT(ownerExecutable->isFunctionExecutable());
     2046                globalTypeSet = jsCast<FunctionExecutable*>(ownerExecutable)->returnStatementTypeSet();
    20472047                globalVariableID = TypeProfilerReturnStatement;
    20482048                if (!shouldAnalyze) {
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r172614 r172949  
    6565#include "RegExpObject.h"
    6666#include "StructureStubInfo.h"
    67 #include "TypeSet.h"
    6867#include "UnconditionalFinalizer.h"
    6968#include "ValueProfile.h"
     
    943942
    944943    bool isKnownToBeLiveDuringGC(); // Will only return valid results when called during GC. Assumes that you've already established that the owner executable is live.
    945     RefPtr<TypeSet> returnStatementTypeSet()
    946     {
    947         if (!m_returnStatementTypeSet)
    948             m_returnStatementTypeSet = TypeSet::create();
    949 
    950         return m_returnStatementTypeSet;
    951     }
    952944
    953945
     
    11001092    std::unique_ptr<BytecodeLivenessAnalysis> m_livenessAnalysis;
    11011093
    1102     RefPtr<TypeSet> m_returnStatementTypeSet;
    1103 
    11041094    struct RareData {
    11051095        WTF_MAKE_FAST_ALLOCATED;
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r172820 r172949  
    4141#include "SamplingTool.h"
    4242#include "SourceCode.h"
     43#include "TypeSet.h"
    4344#include "UnlinkedCodeBlock.h"
    4445#include <wtf/PassOwnPtr.h>
     
    613614        return baselineCodeBlockFor(kind);
    614615    }
     616
     617    RefPtr<TypeSet> returnStatementTypeSet()
     618    {
     619        if (!m_returnStatementTypeSet)
     620            m_returnStatementTypeSet = TypeSet::create();
     621
     622        return m_returnStatementTypeSet;
     623    }
    615624       
    616625    FunctionMode functionMode() { return m_unlinkedExecutable->functionMode(); }
     
    660669    bool m_bodyIncludesBraces;
    661670    bool m_didParseForTheFirstTime;
     671    RefPtr<TypeSet> m_returnStatementTypeSet;
    662672};
    663673
Note: See TracChangeset for help on using the changeset viewer.