Ignore:
Timestamp:
Feb 22, 2019, 1:08:35 AM (6 years ago)
Author:
Tadeu Zagallo
Message:

Cache CompactVariableMap::Handle instead of VariableEnvironment for UnlinkedFunctionExecutable
https://bugs.webkit.org/show_bug.cgi?id=194706

Reviewed by Saam Barati.

In https://bugs.webkit.org/show_bug.cgi?id=194583 we started using a
CompactVariableMap::Handle instead of VariableEnvironment for
UnlinkedFunctionExecutables, but we were creating the full environment
to encode the executable in the bytecode cache. This patch changes it so
that we cache the handle instead of the environment. This avoids duplicating
the VariableEnvironment whenever we have to cache two handles that point
to the environment.

  • bytecode/UnlinkedFunctionExecutable.h:
  • parser/VariableEnvironment.cpp:

(JSC::CompactVariableMap::get):

  • parser/VariableEnvironment.h:
  • runtime/CachedTypes.cpp:

(JSC::CachedCompactVariableEnvironment::encode):
(JSC::CachedCompactVariableEnvironment::decode const):
(JSC::CachedCompactVariableMapHandle::encode):
(JSC::CachedCompactVariableMapHandle::decode const):
(JSC::CachedFunctionExecutable::encode):
(JSC::CachedFunctionExecutable::decode const):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/VariableEnvironment.h

    r241571 r241938  
    126126    WTF_MAKE_FAST_ALLOCATED;
    127127    WTF_MAKE_NONCOPYABLE(CompactVariableEnvironment);
     128
     129    friend class CachedCompactVariableEnvironment;
     130
    128131public:
    129132    CompactVariableEnvironment(const VariableEnvironment&);
     
    134137
    135138private:
     139    CompactVariableEnvironment() = default;
     140
    136141    Vector<RefPtr<UniquedStringImpl>> m_variables;
    137142    Vector<VariableEnvironmentEntry> m_variableMetadata;
     
    205210public:
    206211    class Handle {
     212        friend class CachedCompactVariableMapHandle;
     213
    207214    public:
    208215        Handle() = default;
     
    242249private:
    243250    friend class Handle;
     251    friend class CachedCompactVariableMapHandle;
     252
     253    Handle get(CompactVariableEnvironment*, bool& isNewEntry);
     254
    244255    HashMap<CompactVariableMapKey, unsigned> m_map;
    245256};
Note: See TracChangeset for help on using the changeset viewer.