Ignore:
Timestamp:
Feb 14, 2019, 4:06:30 PM (6 years ago)
Author:
[email protected]
Message:

Cache the results of BytecodeGenerator::getVariablesUnderTDZ
https://bugs.webkit.org/show_bug.cgi?id=194583
<rdar://problem/48028140>

Reviewed by Yusuke Suzuki.

JSTests:

  • microbenchmarks/cache-get-variables-under-tdz-in-bytecode-generator.js: Added.

Source/JavaScriptCore:

This patch makes it so that getVariablesUnderTDZ caches a result of
CompactVariableMap::Handle. getVariablesUnderTDZ is costly when
it's called in an environment where there are a lot of variables.
This patch makes it so we cache its results. This is profitable when
getVariablesUnderTDZ is called repeatedly with the same environment
state. This is common since we call this every time we encounter a
function definition/expression node.

  • builtins/BuiltinExecutables.cpp:

(JSC::BuiltinExecutables::createExecutable):

  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):

  • bytecode/UnlinkedFunctionExecutable.h:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::popLexicalScopeInternal):
(JSC::BytecodeGenerator::liftTDZCheckIfPossible):
(JSC::BytecodeGenerator::pushTDZVariables):
(JSC::BytecodeGenerator::getVariablesUnderTDZ):
(JSC::BytecodeGenerator::restoreTDZStack):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::makeFunction):

  • parser/VariableEnvironment.cpp:

(JSC::CompactVariableMap::Handle::Handle):
(JSC::CompactVariableMap::Handle::operator=):

  • parser/VariableEnvironment.h:

(JSC::CompactVariableMap::Handle::operator bool const):

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getUnlinkedGlobalFunctionExecutable):

File:
1 edited

Legend:

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

    r240255 r241571  
    205205public:
    206206    class Handle {
    207         WTF_MAKE_NONCOPYABLE(Handle); // If we wanted to make this copyable, we'd need to do a hashtable lookup and bump the reference count of the map entry.
    208207    public:
     208        Handle() = default;
     209
    209210        Handle(CompactVariableEnvironment& environment, CompactVariableMap& map)
    210211            : m_environment(&environment)
     
    219220            other.m_environment = nullptr;
    220221        }
     222
     223        Handle(const Handle&);
     224        Handle& operator=(const Handle&);
     225
    221226        ~Handle();
     227
     228        explicit operator bool() const { return !!m_map; }
    222229
    223230        const CompactVariableEnvironment& environment() const
     
    227234
    228235    private:
    229         CompactVariableEnvironment* m_environment;
     236        CompactVariableEnvironment* m_environment { nullptr };
    230237        RefPtr<CompactVariableMap> m_map;
    231238    };
Note: See TracChangeset for help on using the changeset viewer.