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

Changeset 243365 in webkit


Ignore:
Timestamp:
Mar 22, 2019, 12:14:43 AM (7 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Shrink sizeof(FunctionExecutable) by 16bytes
https://bugs.webkit.org/show_bug.cgi?id=196122

Reviewed by Saam Barati.

This patch reduces sizeof(FunctionExecutable) by 16 bytes.

  1. ScriptExecutable::m_numParametersForCall and ScriptExecutable::m_numParametersForConstruct are not used in a meaningful way. Removed them.
  2. ScriptExecutable::m_lastLine and ScriptExecutable::m_endColumn can be calculated from UnlinkedFunctionExecutable. So FunctionExecutable does not need to hold it. This patch adds GlobalExecutable, which are non-function ScriptExecutables, and move m_lastLine and m_endColumn to this class.
  3. FunctionExecutable still needs to have the feature overriding m_lastLine and m_endColumn. We move overridden data in FunctionExecutable::RareData.
  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::UnlinkedFunctionExecutable::link):

  • runtime/EvalExecutable.cpp:

(JSC::EvalExecutable::EvalExecutable):

  • runtime/EvalExecutable.h:
  • runtime/FunctionExecutable.cpp:

(JSC::FunctionExecutable::FunctionExecutable):
(JSC::FunctionExecutable::ensureRareDataSlow):
(JSC::FunctionExecutable::overrideInfo):

  • runtime/FunctionExecutable.h:
  • runtime/GlobalExecutable.cpp: Copied from Source/JavaScriptCore/tools/FunctionOverrides.h.
  • runtime/GlobalExecutable.h: Copied from Source/JavaScriptCore/tools/FunctionOverrides.h.

(JSC::GlobalExecutable::lastLine const):
(JSC::GlobalExecutable::endColumn const):
(JSC::GlobalExecutable::recordParse):
(JSC::GlobalExecutable::GlobalExecutable):

  • runtime/ModuleProgramExecutable.cpp:

(JSC::ModuleProgramExecutable::ModuleProgramExecutable):

  • runtime/ModuleProgramExecutable.h:
  • runtime/ProgramExecutable.cpp:

(JSC::ProgramExecutable::ProgramExecutable):

  • runtime/ProgramExecutable.h:
  • runtime/ScriptExecutable.cpp:

(JSC::ScriptExecutable::clearCode):
(JSC::ScriptExecutable::installCode):
(JSC::ScriptExecutable::hasClearableCode const):
(JSC::ScriptExecutable::newCodeBlockFor):
(JSC::ScriptExecutable::typeProfilingEndOffset const):
(JSC::ScriptExecutable::recordParse):
(JSC::ScriptExecutable::lastLine const):
(JSC::ScriptExecutable::endColumn const):

  • runtime/ScriptExecutable.h:

(JSC::ScriptExecutable::hasJITCodeForCall const):
(JSC::ScriptExecutable::hasJITCodeForConstruct const):
(JSC::ScriptExecutable::recordParse):
(JSC::ScriptExecutable::lastLine const): Deleted.
(JSC::ScriptExecutable::endColumn const): Deleted.

  • tools/FunctionOverrides.h:
Location:
trunk/Source/JavaScriptCore
Files:
16 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r243312 r243365  
    804804    runtime/GenericTypedArrayViewInlines.h
    805805    runtime/GetPutInfo.h
     806    runtime/GlobalExecutable.h
    806807    runtime/HashMapImpl.h
    807808    runtime/Identifier.h
  • trunk/Source/JavaScriptCore/ChangeLog

    r243364 r243365  
     12019-03-21  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Shrink sizeof(FunctionExecutable) by 16bytes
     4        https://bugs.webkit.org/show_bug.cgi?id=196122
     5
     6        Reviewed by Saam Barati.
     7
     8        This patch reduces sizeof(FunctionExecutable) by 16 bytes.
     9
     10        1. ScriptExecutable::m_numParametersForCall and ScriptExecutable::m_numParametersForConstruct are not used in a meaningful way. Removed them.
     11        2. ScriptExecutable::m_lastLine and ScriptExecutable::m_endColumn can be calculated from UnlinkedFunctionExecutable. So FunctionExecutable does not need to hold it.
     12           This patch adds GlobalExecutable, which are non-function ScriptExecutables, and move m_lastLine and m_endColumn to this class.
     13        3. FunctionExecutable still needs to have the feature overriding m_lastLine and m_endColumn. We move overridden data in FunctionExecutable::RareData.
     14
     15        * CMakeLists.txt:
     16        * JavaScriptCore.xcodeproj/project.pbxproj:
     17        * Sources.txt:
     18        * bytecode/UnlinkedFunctionExecutable.cpp:
     19        (JSC::UnlinkedFunctionExecutable::link):
     20        * runtime/EvalExecutable.cpp:
     21        (JSC::EvalExecutable::EvalExecutable):
     22        * runtime/EvalExecutable.h:
     23        * runtime/FunctionExecutable.cpp:
     24        (JSC::FunctionExecutable::FunctionExecutable):
     25        (JSC::FunctionExecutable::ensureRareDataSlow):
     26        (JSC::FunctionExecutable::overrideInfo):
     27        * runtime/FunctionExecutable.h:
     28        * runtime/GlobalExecutable.cpp: Copied from Source/JavaScriptCore/tools/FunctionOverrides.h.
     29        * runtime/GlobalExecutable.h: Copied from Source/JavaScriptCore/tools/FunctionOverrides.h.
     30        (JSC::GlobalExecutable::lastLine const):
     31        (JSC::GlobalExecutable::endColumn const):
     32        (JSC::GlobalExecutable::recordParse):
     33        (JSC::GlobalExecutable::GlobalExecutable):
     34        * runtime/ModuleProgramExecutable.cpp:
     35        (JSC::ModuleProgramExecutable::ModuleProgramExecutable):
     36        * runtime/ModuleProgramExecutable.h:
     37        * runtime/ProgramExecutable.cpp:
     38        (JSC::ProgramExecutable::ProgramExecutable):
     39        * runtime/ProgramExecutable.h:
     40        * runtime/ScriptExecutable.cpp:
     41        (JSC::ScriptExecutable::clearCode):
     42        (JSC::ScriptExecutable::installCode):
     43        (JSC::ScriptExecutable::hasClearableCode const):
     44        (JSC::ScriptExecutable::newCodeBlockFor):
     45        (JSC::ScriptExecutable::typeProfilingEndOffset const):
     46        (JSC::ScriptExecutable::recordParse):
     47        (JSC::ScriptExecutable::lastLine const):
     48        (JSC::ScriptExecutable::endColumn const):
     49        * runtime/ScriptExecutable.h:
     50        (JSC::ScriptExecutable::hasJITCodeForCall const):
     51        (JSC::ScriptExecutable::hasJITCodeForConstruct const):
     52        (JSC::ScriptExecutable::recordParse):
     53        (JSC::ScriptExecutable::lastLine const): Deleted.
     54        (JSC::ScriptExecutable::endColumn const): Deleted.
     55        * tools/FunctionOverrides.h:
     56
    1572019-03-21  Yusuke Suzuki  <ysuzuki@apple.com>
    258
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r243312 r243365  
    17671767                E354622B1B6065D100545386 /* ConstructAbility.h in Headers */ = {isa = PBXBuildFile; fileRef = E354622A1B6065D100545386 /* ConstructAbility.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17681768                E3555B8A1DAE03A500F36921 /* DOMJITCallDOMGetterSnippet.h in Headers */ = {isa = PBXBuildFile; fileRef = E3555B891DAE03A200F36921 /* DOMJITCallDOMGetterSnippet.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1769                E355D38F22446877008F1AD6 /* GlobalExecutable.h in Headers */ = {isa = PBXBuildFile; fileRef = E355D38D2244686B008F1AD6 /* GlobalExecutable.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17691770                E35A0B9D220AD87A00AC4474 /* ExecutableBaseInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E35A0B9C220AD87A00AC4474 /* ExecutableBaseInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17701771                E35CA1541DBC3A5C00F83516 /* DOMJITHeapRange.h in Headers */ = {isa = PBXBuildFile; fileRef = E35CA1521DBC3A5600F83516 /* DOMJITHeapRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    47174718                E354622A1B6065D100545386 /* ConstructAbility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstructAbility.h; sourceTree = "<group>"; };
    47184719                E3555B891DAE03A200F36921 /* DOMJITCallDOMGetterSnippet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITCallDOMGetterSnippet.h; sourceTree = "<group>"; };
     4720                E355D38D2244686B008F1AD6 /* GlobalExecutable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlobalExecutable.h; sourceTree = "<group>"; };
     4721                E355D38E2244686C008F1AD6 /* GlobalExecutable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GlobalExecutable.cpp; sourceTree = "<group>"; };
    47194722                E35A0B9C220AD87A00AC4474 /* ExecutableBaseInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExecutableBaseInlines.h; sourceTree = "<group>"; };
    47204723                E35CA14F1DBC3A5600F83516 /* DOMJITAbstractHeap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMJITAbstractHeap.cpp; sourceTree = "<group>"; };
     
    68076810                                BC02E9B80E184545000F9297 /* GetterSetter.cpp */,
    68086811                                BC337BDE0E1AF0B80076918A /* GetterSetter.h */,
     6812                                E355D38E2244686C008F1AD6 /* GlobalExecutable.cpp */,
     6813                                E355D38D2244686B008F1AD6 /* GlobalExecutable.h */,
    68096814                                79A0907D1D768465008B889B /* HashMapImpl.cpp */,
    68106815                                79A0907E1D768465008B889B /* HashMapImpl.h */,
     
    91279132                                0FEC3C5B1F33A48900F59B6C /* GigacageAlignedMemoryAllocator.h in Headers */,
    91289133                                14AD910E1DCA92940014F9FE /* GlobalCodeBlock.h in Headers */,
     9134                                E355D38F22446877008F1AD6 /* GlobalExecutable.h in Headers */,
    91299135                                0F24E54417EA9F5900ABB217 /* GPRInfo.h in Headers */,
    91309136                                142E3134134FF0A600AFADB5 /* Handle.h in Headers */,
  • trunk/Source/JavaScriptCore/Sources.txt

    r243279 r243365  
    769769runtime/GetPutInfo.cpp
    770770runtime/GetterSetter.cpp
     771runtime/GlobalExecutable.cpp
    771772runtime/HashMapImpl.cpp
    772773runtime/Identifier.cpp
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp

    r242605 r243365  
    159159{
    160160    SourceCode source = linkedSourceCode(passedParentSource);
    161     unsigned firstLine = source.firstLine().oneBasedInt();
    162     unsigned lineCount = m_lineCount;
    163     unsigned endColumn = linkedEndColumn(source.startColumn().oneBasedInt());
    164161    FunctionOverrides::OverrideInfo overrideInfo;
    165162    bool hasFunctionOverride = false;
    166     if (UNLIKELY(Options::functionOverrides())) {
     163    if (UNLIKELY(Options::functionOverrides()))
    167164        hasFunctionOverride = FunctionOverrides::initializeOverrideFor(source, overrideInfo);
    168         if (UNLIKELY(hasFunctionOverride)) {
    169             firstLine = overrideInfo.firstLine;
    170             lineCount = overrideInfo.lineCount;
    171             endColumn = overrideInfo.endColumn;
    172             source = overrideInfo.sourceCode;
    173         }
    174     }
    175 
    176     FunctionExecutable* result = FunctionExecutable::create(vm, source, this, firstLine + lineCount, endColumn, intrinsic);
     165
     166    FunctionExecutable* result = FunctionExecutable::create(vm, source, this, intrinsic);
    177167    if (overrideLineNumber)
    178168        result->setOverrideLineNumber(*overrideLineNumber);
    179169
    180     if (UNLIKELY(hasFunctionOverride)) {
    181         result->overrideParameterAndTypeProfilingStartEndOffsets(
    182             overrideInfo.parametersStartOffset,
    183             overrideInfo.typeProfilingStartOffset,
    184             overrideInfo.typeProfilingEndOffset);
    185     }
     170    if (UNLIKELY(hasFunctionOverride))
     171        result->overrideInfo(overrideInfo);
    186172
    187173    return result;
  • trunk/Source/JavaScriptCore/runtime/EvalExecutable.cpp

    r233085 r243365  
    3232namespace JSC {
    3333
    34 const ClassInfo EvalExecutable::s_info = { "EvalExecutable", &ScriptExecutable::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(EvalExecutable) };
     34const ClassInfo EvalExecutable::s_info = { "EvalExecutable", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(EvalExecutable) };
    3535
    3636EvalExecutable::EvalExecutable(ExecState* exec, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, bool isArrowFunctionContext, EvalContextType evalContextType)
    37     : ScriptExecutable(exec->vm().evalExecutableStructure.get(), exec->vm(), source, inStrictContext, derivedContextType, isArrowFunctionContext, evalContextType, NoIntrinsic)
     37    : Base(exec->vm().evalExecutableStructure.get(), exec->vm(), source, inStrictContext, derivedContextType, isArrowFunctionContext, evalContextType, NoIntrinsic)
    3838{
    3939    ASSERT(source.provider()->sourceType() == SourceProviderSourceType::Program);
  • trunk/Source/JavaScriptCore/runtime/EvalExecutable.h

    r241038 r243365  
    2727
    2828#include "ExecutableToCodeBlockEdge.h"
    29 #include "ScriptExecutable.h"
     29#include "GlobalExecutable.h"
    3030#include "UnlinkedEvalCodeBlock.h"
    3131
    3232namespace JSC {
    3333
    34 class EvalExecutable : public ScriptExecutable {
     34class EvalExecutable : public GlobalExecutable {
    3535    friend class LLIntOffsetsExtractor;
    3636public:
    37     typedef ScriptExecutable Base;
     37    using Base = GlobalExecutable;
    3838    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    3939
  • trunk/Source/JavaScriptCore/runtime/FunctionExecutable.cpp

    r240938 r243365  
    3030#include "Debugger.h"
    3131#include "FunctionCodeBlock.h"
     32#include "FunctionOverrides.h"
    3233#include "JIT.h"
    3334#include "JSCInlines.h"
     
    4243const ClassInfo FunctionExecutable::s_info = { "FunctionExecutable", &ScriptExecutable::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(FunctionExecutable) };
    4344
    44 FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned lastLine, unsigned endColumn, Intrinsic intrinsic)
     45static_assert(sizeof(FunctionExecutable) <= 128, "FunctionExecutable should fit in a 128-byte cell since it is so frequently allocated.");
     46
     47FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, Intrinsic intrinsic)
    4548    : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext(), unlinkedExecutable->derivedContextType(), false, EvalContextType::None, intrinsic)
    4649    , m_unlinkedExecutable(vm, this, unlinkedExecutable)
     
    4851    RELEASE_ASSERT(!source.isNull());
    4952    ASSERT(source.length());
    50     m_lastLine = lastLine;
    51     ASSERT(endColumn != UINT_MAX);
    52     m_endColumn = endColumn;
    5353    if (VM::canUseJIT())
    5454        new (&m_singletonFunction) WriteBarrier<InferredValue>();
     
    112112{
    113113    ASSERT(!m_rareData);
    114     m_rareData = std::make_unique<RareData>();
    115     m_rareData->m_parametersStartOffset = m_unlinkedExecutable->parametersStartOffset();
    116     m_rareData->m_typeProfilingStartOffset = m_unlinkedExecutable->typeProfilingStartOffset();
    117     m_rareData->m_typeProfilingEndOffset = m_unlinkedExecutable->typeProfilingEndOffset();
     114    auto rareData = std::make_unique<RareData>();
     115    rareData->m_lineCount = lineCount();
     116    rareData->m_endColumn = endColumn();
     117    rareData->m_parametersStartOffset = parametersStartOffset();
     118    rareData->m_typeProfilingStartOffset = typeProfilingStartOffset();
     119    rareData->m_typeProfilingEndOffset = typeProfilingEndOffset();
     120    m_rareData = WTFMove(rareData);
    118121    return *m_rareData;
    119122}
    120123
     124void FunctionExecutable::overrideInfo(const FunctionOverrideInfo& overrideInfo)
     125{
     126    auto& rareData = ensureRareData();
     127    m_source = overrideInfo.sourceCode;
     128    rareData.m_lineCount = overrideInfo.lineCount;
     129    rareData.m_endColumn = overrideInfo.endColumn;
     130    rareData.m_parametersStartOffset = overrideInfo.parametersStartOffset;
     131    rareData.m_typeProfilingStartOffset = overrideInfo.typeProfilingStartOffset;
     132    rareData.m_typeProfilingEndOffset = overrideInfo.typeProfilingEndOffset;
     133}
     134
    121135} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/FunctionExecutable.h

    r241645 r243365  
    3434namespace JSC {
    3535
     36struct FunctionOverrideInfo;
     37
    3638class FunctionExecutable final : public ScriptExecutable {
    3739    friend class JIT;
     
    4749    }
    4850
    49     static FunctionExecutable* create(
    50         VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable,
    51         unsigned lastLine, unsigned endColumn, Intrinsic intrinsic)
    52     {
    53         FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, lastLine, endColumn, intrinsic);
     51    static FunctionExecutable* create(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, Intrinsic intrinsic)
     52    {
     53        FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, intrinsic);
    5454        executable->finishCreation(vm);
    5555        return executable;
     
    191191    }
    192192
     193    int lineCount() const
     194    {
     195        if (UNLIKELY(m_rareData))
     196            return m_rareData->m_lineCount;
     197        return m_unlinkedExecutable->lineCount();
     198    }
     199
     200    int endColumn() const
     201    {
     202        if (UNLIKELY(m_rareData))
     203            return m_rareData->m_endColumn;
     204        return m_unlinkedExecutable->linkedEndColumn(m_source.startColumn().oneBasedInt());
     205    }
     206
     207    int firstLine() const
     208    {
     209        return source().firstLine().oneBasedInt();
     210    }
     211
     212    int lastLine() const
     213    {
     214        return firstLine() + lineCount();
     215    }
     216
    193217    unsigned typeProfilingStartOffset(VM&) const
     218    {
     219        return typeProfilingStartOffset();
     220    }
     221
     222    unsigned typeProfilingStartOffset() const
    194223    {
    195224        if (UNLIKELY(m_rareData))
     
    200229    unsigned typeProfilingEndOffset(VM&) const
    201230    {
     231        return typeProfilingEndOffset();
     232    }
     233
     234    unsigned typeProfilingEndOffset() const
     235    {
    202236        if (UNLIKELY(m_rareData))
    203237            return m_rareData->m_typeProfilingEndOffset;
     
    212246    }
    213247
    214     void overrideParameterAndTypeProfilingStartEndOffsets(unsigned parametersStartOffset, unsigned typeProfilingStartOffset, unsigned typeProfilingEndOffset)
    215     {
    216         auto& rareData = ensureRareData();
    217         rareData.m_parametersStartOffset = parametersStartOffset;
    218         rareData.m_typeProfilingStartOffset = typeProfilingStartOffset;
    219         rareData.m_typeProfilingEndOffset = typeProfilingEndOffset;
    220     }
     248    void overrideInfo(const FunctionOverrideInfo&);
    221249
    222250    DECLARE_INFO;
     
    269297private:
    270298    friend class ExecutableBase;
    271     FunctionExecutable(
    272         VM&, const SourceCode&, UnlinkedFunctionExecutable*,
    273         unsigned lastLine, unsigned endColumn, Intrinsic);
     299    FunctionExecutable(VM&, const SourceCode&, UnlinkedFunctionExecutable*, Intrinsic);
    274300   
    275301    void finishCreation(VM&);
     
    279305    struct RareData {
    280306        WTF_MAKE_STRUCT_FAST_ALLOCATED;
     307        RefPtr<TypeSet> m_returnStatementTypeSet;
     308        unsigned m_lineCount;
     309        unsigned m_endColumn;
    281310        Markable<int, IntegralMarkableTraits<int, -1>> m_overrideLineNumber;
    282311        unsigned m_parametersStartOffset { 0 };
    283312        unsigned m_typeProfilingStartOffset { UINT_MAX };
    284313        unsigned m_typeProfilingEndOffset { UINT_MAX };
    285         RefPtr<TypeSet> m_returnStatementTypeSet;
    286314    };
    287315
  • trunk/Source/JavaScriptCore/runtime/GlobalExecutable.cpp

    r243364 r243365  
    11/*
    2  * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2424 */
    2525
    26 #pragma once
    27 
    28 #include "SourceCode.h"
    29 #include <wtf/HashMap.h>
    30 #include <wtf/text/WTFString.h>
     26#include "config.h"
     27#include "GlobalExecutable.h"
    3128
    3229namespace JSC {
    3330
    34 class ScriptExecutable;
    35 
    36 class FunctionOverrides {
    37 public:
    38     struct OverrideInfo {
    39         SourceCode sourceCode;
    40         unsigned firstLine;
    41         unsigned lineCount;
    42         unsigned startColumn;
    43         unsigned endColumn;
    44         unsigned parametersStartOffset;
    45         unsigned typeProfilingStartOffset;
    46         unsigned typeProfilingEndOffset;
    47     };
    48 
    49     static FunctionOverrides& overrides();
    50     FunctionOverrides(const char* functionOverridesFileName);
    51 
    52     static bool initializeOverrideFor(const SourceCode& origCode, OverrideInfo& result);
    53 
    54     JS_EXPORT_PRIVATE static void reinstallOverrides();
    55 
    56 private:
    57     void parseOverridesInFile(const char* fileName);
    58     void clear() { m_entries.clear(); }
    59 
    60     HashMap<String, String> m_entries;
    61 };
     31const ClassInfo GlobalExecutable::s_info = { "GlobalExecutable", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(GlobalExecutable) };
    6232
    6333} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/GlobalExecutable.h

    r243364 r243365  
    11/*
    2  * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SourceCode.h"
    29 #include <wtf/HashMap.h>
    30 #include <wtf/text/WTFString.h>
     28#include "ExecutableToCodeBlockEdge.h"
     29#include "ScriptExecutable.h"
    3130
    3231namespace JSC {
    3332
    34 class ScriptExecutable;
     33class GlobalExecutable : public ScriptExecutable {
     34public:
     35    using Base = ScriptExecutable;
     36    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    3537
    36 class FunctionOverrides {
    37 public:
    38     struct OverrideInfo {
    39         SourceCode sourceCode;
    40         unsigned firstLine;
    41         unsigned lineCount;
    42         unsigned startColumn;
    43         unsigned endColumn;
    44         unsigned parametersStartOffset;
    45         unsigned typeProfilingStartOffset;
    46         unsigned typeProfilingEndOffset;
    47     };
     38    DECLARE_INFO;
    4839
    49     static FunctionOverrides& overrides();
    50     FunctionOverrides(const char* functionOverridesFileName);
     40    unsigned lastLine() const { return m_lastLine; }
     41    unsigned endColumn() const { return m_endColumn; }
    5142
    52     static bool initializeOverrideFor(const SourceCode& origCode, OverrideInfo& result);
     43    void recordParse(CodeFeatures features, bool hasCapturedVariables, int lastLine, unsigned endColumn)
     44    {
     45        Base::recordParse(features, hasCapturedVariables);
     46        m_lastLine = lastLine;
     47        m_endColumn = endColumn;
     48        ASSERT(endColumn != UINT_MAX);
     49    }
    5350
    54     JS_EXPORT_PRIVATE static void reinstallOverrides();
     51protected:
     52    GlobalExecutable(Structure* structure, VM& vm, const SourceCode& sourceCode, bool isInStrictContext, DerivedContextType derivedContextType, bool isInArrowFunctionContext, EvalContextType evalContextType, Intrinsic intrinsic)
     53        : Base(structure, vm, sourceCode, isInStrictContext, derivedContextType, isInArrowFunctionContext, evalContextType, intrinsic)
     54    {
     55    }
    5556
    56 private:
    57     void parseOverridesInFile(const char* fileName);
    58     void clear() { m_entries.clear(); }
    59 
    60     HashMap<String, String> m_entries;
     57    int m_lastLine { -1 };
     58    unsigned m_endColumn { UINT_MAX };
    6159};
    6260
  • trunk/Source/JavaScriptCore/runtime/ModuleProgramExecutable.cpp

    r240938 r243365  
    4141namespace JSC {
    4242
    43 const ClassInfo ModuleProgramExecutable::s_info = { "ModuleProgramExecutable", &ScriptExecutable::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ModuleProgramExecutable) };
     43const ClassInfo ModuleProgramExecutable::s_info = { "ModuleProgramExecutable", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ModuleProgramExecutable) };
    4444
    4545ModuleProgramExecutable::ModuleProgramExecutable(ExecState* exec, const SourceCode& source)
    46     : ScriptExecutable(exec->vm().moduleProgramExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false, EvalContextType::None, NoIntrinsic)
     46    : Base(exec->vm().moduleProgramExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false, EvalContextType::None, NoIntrinsic)
    4747{
    4848    ASSERT(source.provider()->sourceType() == SourceProviderSourceType::Module);
  • trunk/Source/JavaScriptCore/runtime/ModuleProgramExecutable.h

    r240965 r243365  
    2727
    2828#include "ExecutableToCodeBlockEdge.h"
    29 #include "ScriptExecutable.h"
     29#include "GlobalExecutable.h"
    3030
    3131namespace JSC {
    3232
    33 class ModuleProgramExecutable final : public ScriptExecutable {
     33class ModuleProgramExecutable final : public GlobalExecutable {
    3434    friend class LLIntOffsetsExtractor;
    3535public:
    36     typedef ScriptExecutable Base;
     36    using Base = GlobalExecutable;
    3737    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    3838
  • trunk/Source/JavaScriptCore/runtime/ProgramExecutable.cpp

    r242596 r243365  
    4242namespace JSC {
    4343
    44 const ClassInfo ProgramExecutable::s_info = { "ProgramExecutable", &ScriptExecutable::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ProgramExecutable) };
     44const ClassInfo ProgramExecutable::s_info = { "ProgramExecutable", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ProgramExecutable) };
    4545
    4646ProgramExecutable::ProgramExecutable(ExecState* exec, const SourceCode& source)
    47     : ScriptExecutable(exec->vm().programExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false, EvalContextType::None, NoIntrinsic)
     47    : Base(exec->vm().programExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false, EvalContextType::None, NoIntrinsic)
    4848{
    4949    ASSERT(source.provider()->sourceType() == SourceProviderSourceType::Program);
  • trunk/Source/JavaScriptCore/runtime/ProgramExecutable.h

    r240965 r243365  
    2727
    2828#include "ExecutableToCodeBlockEdge.h"
    29 #include "ScriptExecutable.h"
     29#include "GlobalExecutable.h"
    3030
    3131namespace JSC {
    3232
    33 class ProgramExecutable final : public ScriptExecutable {
     33class ProgramExecutable final : public GlobalExecutable {
    3434    friend class LLIntOffsetsExtractor;
    3535public:
    36     typedef ScriptExecutable Base;
     36    using Base = GlobalExecutable;
    3737    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    3838
  • trunk/Source/JavaScriptCore/runtime/ScriptExecutable.cpp

    r243136 r243365  
    3131#include "EvalCodeBlock.h"
    3232#include "FunctionCodeBlock.h"
     33#include "GlobalExecutable.h"
    3334#include "IsoCellSetInlines.h"
    3435#include "JIT.h"
     
    6970void ScriptExecutable::clearCode(IsoCellSet& clearableCodeSet)
    7071{
    71 #if ENABLE(JIT)
    7272    m_jitCodeForCall = nullptr;
    7373    m_jitCodeForConstruct = nullptr;
    7474    m_jitCodeForCallWithArityCheck = MacroAssemblerCodePtr<JSEntryPtrTag>();
    7575    m_jitCodeForConstructWithArityCheck = MacroAssemblerCodePtr<JSEntryPtrTag>();
    76 #endif
    77     m_numParametersForCall = NUM_PARAMETERS_NOT_COMPILED;
    78     m_numParametersForConstruct = NUM_PARAMETERS_NOT_COMPILED;
    7976
    8077    switch (type()) {
     
    181178        m_jitCodeForCall = genericCodeBlock ? genericCodeBlock->jitCode() : nullptr;
    182179        m_jitCodeForCallWithArityCheck = nullptr;
    183         m_numParametersForCall = genericCodeBlock ? genericCodeBlock->numParameters() : NUM_PARAMETERS_NOT_COMPILED;
    184180        break;
    185181    case CodeForConstruct:
    186182        m_jitCodeForConstruct = genericCodeBlock ? genericCodeBlock->jitCode() : nullptr;
    187183        m_jitCodeForConstructWithArityCheck = nullptr;
    188         m_numParametersForConstruct = genericCodeBlock ? genericCodeBlock->numParameters() : NUM_PARAMETERS_NOT_COMPILED;
    189184        break;
    190185    }
     
    219214bool ScriptExecutable::hasClearableCode(VM& vm) const
    220215{
    221 #if ENABLE(JIT)
    222216    if (m_jitCodeForCall
    223217        || m_jitCodeForConstruct
     
    225219        || m_jitCodeForConstructWithArityCheck)
    226220        return true;
    227 #endif
    228221
    229222    if (structure(vm)->classInfo() == FunctionExecutable::info()) {
     
    323316    UnlinkedFunctionCodeBlock* unlinkedCodeBlock =
    324317        executable->m_unlinkedExecutable->unlinkedCodeBlockFor(
    325             *vm, executable->m_source, kind, debuggerMode, error,
     318            *vm, executable->source(), kind, debuggerMode, error,
    326319            executable->parseMode());
    327320    recordParse(
     
    332325        exception = throwException(
    333326            globalObject->globalExec(), throwScope,
    334             error.toErrorObject(globalObject, executable->m_source));
     327            error.toErrorObject(globalObject, executable->source()));
    335328        return nullptr;
    336329    }
     
    460453    if (inherits<EvalExecutable>(vm))
    461454        return UINT_MAX;
    462     return m_source.length() - 1;
     455    return source().length() - 1;
     456}
     457
     458void ScriptExecutable::recordParse(CodeFeatures features, bool hasCapturedVariables, int lastLine, unsigned endColumn)
     459{
     460    switch (type()) {
     461    case FunctionExecutableType:
     462        // Since UnlinkedFunctionExecutable holds the information to calculate lastLine and endColumn, we do not need to remember them in ScriptExecutable's fields.
     463        jsCast<FunctionExecutable*>(this)->recordParse(features, hasCapturedVariables);
     464        return;
     465    default:
     466        jsCast<GlobalExecutable*>(this)->recordParse(features, hasCapturedVariables, lastLine, endColumn);
     467        return;
     468    }
     469}
     470
     471int ScriptExecutable::lastLine() const
     472{
     473    switch (type()) {
     474    case FunctionExecutableType:
     475        return jsCast<const FunctionExecutable*>(this)->lastLine();
     476    default:
     477        return jsCast<const GlobalExecutable*>(this)->lastLine();
     478    }
     479    return 0;
     480}
     481
     482unsigned ScriptExecutable::endColumn() const
     483{
     484    switch (type()) {
     485    case FunctionExecutableType:
     486        return jsCast<const FunctionExecutable*>(this)->endColumn();
     487    default:
     488        return jsCast<const GlobalExecutable*>(this)->endColumn();
     489    }
     490    return 0;
    463491}
    464492
  • trunk/Source/JavaScriptCore/runtime/ScriptExecutable.h

    r242596 r243365  
    4646    const String& sourceURL() const { return m_source.provider()->url(); }
    4747    int firstLine() const { return m_source.firstLine().oneBasedInt(); }
    48     int lastLine() const { return m_lastLine; }
     48    JS_EXPORT_PRIVATE int lastLine() const;
    4949    unsigned startColumn() const { return m_source.startColumn().oneBasedInt(); }
    50     unsigned endColumn() const { return m_endColumn; }
     50    JS_EXPORT_PRIVATE unsigned endColumn() const;
    5151
    5252    Optional<int> overrideLineNumber(VM&) const;
     
    8282    DECLARE_EXPORT_INFO;
    8383
    84     void recordParse(CodeFeatures features, bool hasCapturedVariables, int lastLine, unsigned endColumn)
    85     {
    86         m_features = features;
    87         m_hasCapturedVariables = hasCapturedVariables;
    88         m_lastLine = lastLine;
    89         ASSERT(endColumn != UINT_MAX);
    90         m_endColumn = endColumn;
    91     }
    92 
     84    void recordParse(CodeFeatures, bool hasCapturedVariables, int lastLine, unsigned endColumn);
    9385    void installCode(CodeBlock*);
    9486    void installCode(VM&, CodeBlock*, CodeType, CodeSpecializationKind);
     
    10395    }
    10496
    105     static constexpr int NUM_PARAMETERS_NOT_COMPILED = -1;
    106 
    10797    bool hasJITCodeForCall() const
    10898    {
    109         return m_numParametersForCall >= 0;
     99        return m_jitCodeForCall;
    110100    }
    111101    bool hasJITCodeForConstruct() const
    112102    {
    113         return m_numParametersForConstruct >= 0;
     103        return m_jitCodeForConstruct;
    114104    }
    115105
     
    142132    }
    143133
     134    void recordParse(CodeFeatures features, bool hasCapturedVariables)
     135    {
     136        m_features = features;
     137        m_hasCapturedVariables = hasCapturedVariables;
     138    }
     139
    144140    SourceCode m_source;
    145 
    146     int m_numParametersForCall { NUM_PARAMETERS_NOT_COMPILED };
    147     int m_numParametersForConstruct { NUM_PARAMETERS_NOT_COMPILED };
    148 
    149     int m_lastLine { -1 };
    150     unsigned m_endColumn { UINT_MAX };
    151 
    152141    Intrinsic m_intrinsic { NoIntrinsic };
    153142    bool m_didTryToEnterInLoop { false };
  • trunk/Source/JavaScriptCore/tools/FunctionOverrides.h

    r218794 r243365  
    3434class ScriptExecutable;
    3535
     36struct FunctionOverrideInfo {
     37    SourceCode sourceCode;
     38    unsigned firstLine;
     39    unsigned lineCount;
     40    unsigned startColumn;
     41    unsigned endColumn;
     42    unsigned parametersStartOffset;
     43    unsigned typeProfilingStartOffset;
     44    unsigned typeProfilingEndOffset;
     45};
     46
    3647class FunctionOverrides {
    3748public:
    38     struct OverrideInfo {
    39         SourceCode sourceCode;
    40         unsigned firstLine;
    41         unsigned lineCount;
    42         unsigned startColumn;
    43         unsigned endColumn;
    44         unsigned parametersStartOffset;
    45         unsigned typeProfilingStartOffset;
    46         unsigned typeProfilingEndOffset;
    47     };
     49    using OverrideInfo = FunctionOverrideInfo;
    4850
    4951    static FunctionOverrides& overrides();
Note: See TracChangeset for help on using the changeset viewer.