Ignore:
Timestamp:
Jun 7, 2021, 8:22:27 PM (4 years ago)
Author:
[email protected]
Message:

[JSC] Use ResolvedClosureVar to get brand from scope
https://bugs.webkit.org/show_bug.cgi?id=226677
rdar://78802869

Reviewed by Saam Barati.

JSTests:

  • stress/private-access-nested-eval.js: Added.

(shouldThrow):
(shouldThrow.prototype.x):
(shouldThrow.prototype.m.C.prototype.z):
(shouldThrow.prototype.m.C.prototype.a):
(shouldThrow.prototype.m.C):
(shouldThrow.prototype.m):

  • stress/private-access-nested.js: Added.

(shouldThrow):
(shouldThrow.prototype.x):
(shouldThrow.prototype.m.C.prototype.z):
(shouldThrow.prototype.m.C.prototype.a):
(shouldThrow.prototype.m.C):
(shouldThrow.prototype.m):

Source/JavaScriptCore:

Private brand lookup is doing wrong way to get scope.

  1. op_resolve_scope with private name (e.g. #x)
  2. then, doing op_get_from_scope with (1)'s scope with different name (e.g. @privateBrand)

This is wrong in JSC. We resolve scope at link-time in CodeBlock. So we need to ensure that both op_resolve_scope and op_get_from_scope
starts with the current scope-register. As a result, private-brand lookup is broken right now. Let's see the buggy case.

class D {

#x() {}
m() {

class C {

#yy;
#z() { }
a() {

this.#x(); <===== This point.

}

}
let c = new C();
c.a();

}

}

In the above point, we first lookup the scope with #x, and we get the D's class-scope. But our get_from_scope is using privateBrand, and
privateBrand property exists too in C's class-scope too since C also has #yy and #z. As a result, CodeBlock linking configures the offset for
C's class-scope in get_from_scope. And this offset is different from D's class-scope's privateBrand.

Only allowed case for the above usage is ResolvedClosureVar. And generatorification uses it too. In this patch,

  1. We ensure that class-scope (with private name) must have @privateBrand and @privateClassBrand with offset 1 and 0.
  2. Use ResolvedClosureVar with the above pre-defined offset

Since CodeBlock's linking does not resolve the scope for get_from_scope if it is ResolvedClosureVar, we can just perform the desired ResolvedClosureVar lookup
with the given scope with the compiled offset.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::instantiateLexicalVariables):
(JSC::BytecodeGenerator::pushLexicalScope):
(JSC::BytecodeGenerator::pushLexicalScopeInternal):
(JSC::BytecodeGenerator::emitCreatePrivateBrand):
(JSC::BytecodeGenerator::emitGetPrivateBrand):

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::BaseDotNode::emitGetPropertyValue):
(JSC::BaseDotNode::emitPutProperty):
(JSC::PostfixNode::emitDot):
(JSC::PrefixNode::emitDot):
(JSC::InNode::emitBytecode):
(JSC::BlockNode::emitBytecode):
(JSC::ForNode::emitBytecode):
(JSC::ForInNode::emitBytecode):
(JSC::ForOfNode::emitBytecode):
(JSC::SwitchNode::emitBytecode):
(JSC::ClassExprNode::emitBytecode):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseClass):

  • parser/VariableEnvironment.h:
Location:
trunk/Source/JavaScriptCore/bytecompiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r278588 r278591  
    529529                    functionSymbolTable->set(NoLockingNecessary, name, entry);
    530530                }
    531                 OpPutToScope::emit(this, m_lexicalEnvironmentRegister, UINT_MAX, virtualRegisterForArgumentIncludingThis(1 + i), GetPutInfo(ThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization, ecmaMode), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset());
     531                OpPutToScope::emit(this, m_lexicalEnvironmentRegister, UINT_MAX, virtualRegisterForArgumentIncludingThis(1 + i), GetPutInfo(ThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, ecmaMode), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset());
    532532            }
    533533           
     
    567567            functionSymbolTable->set(NoLockingNecessary, name, SymbolTableEntry(VarOffset(offset)));
    568568           
    569             OpPutToScope::emit(this, m_lexicalEnvironmentRegister, addConstant(ident), virtualRegisterForArgumentIncludingThis(1 + i), GetPutInfo(ThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization, ecmaMode), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset());
     569            OpPutToScope::emit(this, m_lexicalEnvironmentRegister, addConstant(ident), virtualRegisterForArgumentIncludingThis(1 + i), GetPutInfo(ThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, ecmaMode), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset());
    570570        }
    571571    }
     
    843843
    844844    bool shouldInitializeBlockScopedFunctions = false; // We generate top-level function declarations in ::generate().
    845     pushLexicalScope(m_scopeNode, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, shouldInitializeBlockScopedFunctions);
     845    pushLexicalScope(m_scopeNode, ScopeType::LetConstScope, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, shouldInitializeBlockScopedFunctions);
    846846}
    847847
     
    908908   
    909909    bool shouldInitializeBlockScopedFunctions = false; // We generate top-level function declarations in ::generate().
    910     pushLexicalScope(m_scopeNode, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, shouldInitializeBlockScopedFunctions);
     910    pushLexicalScope(m_scopeNode, ScopeType::LetConstScope, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, shouldInitializeBlockScopedFunctions);
    911911}
    912912
     
    990990
    991991    VariableEnvironment& lexicalVariables = moduleProgramNode->lexicalVariables();
    992     instantiateLexicalVariables(lexicalVariables, moduleEnvironmentSymbolTable, ScopeRegisterType::Block, lookUpVarKind);
     992    instantiateLexicalVariables(lexicalVariables, ScopeType::LetConstScope, moduleEnvironmentSymbolTable, ScopeRegisterType::Block, lookUpVarKind);
    993993
    994994    // We keep the symbol table in the constant pool.
     
    18641864
    18651865template<typename LookUpVarKindFunctor>
    1866 bool BytecodeGenerator::instantiateLexicalVariables(const VariableEnvironment& lexicalVariables, SymbolTable* symbolTable, ScopeRegisterType scopeRegisterType, LookUpVarKindFunctor lookUpVarKind)
     1866bool BytecodeGenerator::instantiateLexicalVariables(const VariableEnvironment& lexicalVariables, ScopeType scopeType, SymbolTable* symbolTable, ScopeRegisterType scopeRegisterType, LookUpVarKindFunctor lookUpVarKind)
    18671867{
    18681868    bool hasCapturedVariables = false;
    18691869    {
     1870        bool hasPrivateNames = lexicalVariables.privateNamesSize();
     1871        // We need to ensure that @privateClassBrand and @privateBrand offsets are 0 and 1 respectively.
     1872        // To ensure that, we first define them, and later, we filter them out from lexicalVariables.
     1873        if (scopeType == ScopeType::ClassScope) {
     1874            if (hasPrivateNames) {
     1875                hasCapturedVariables = true;
     1876                VarOffset privateClassBrandOffset = VarOffset(symbolTable->takeNextScopeOffset(NoLockingNecessary));
     1877                ASSERT(privateClassBrandOffset.rawOffset() == PrivateNameEntry::privateClassBrandOffset);
     1878                symbolTable->add(NoLockingNecessary, propertyNames().builtinNames().privateClassBrandPrivateName().impl(), SymbolTableEntry { privateClassBrandOffset, static_cast<unsigned>(PropertyAttribute::ReadOnly) });
     1879
     1880                VarOffset privateBrandOffset = VarOffset(symbolTable->takeNextScopeOffset(NoLockingNecessary));
     1881                ASSERT(privateBrandOffset.rawOffset() == PrivateNameEntry::privateBrandOffset);
     1882                symbolTable->add(NoLockingNecessary, propertyNames().builtinNames().privateBrandPrivateName().impl(), SymbolTableEntry { privateBrandOffset, static_cast<unsigned>(PropertyAttribute::ReadOnly) });
     1883            }
     1884        }
     1885
    18701886        for (auto& entry : lexicalVariables) {
    18711887            ASSERT(entry.value.isLet() || entry.value.isConst() || entry.value.isFunction());
    18721888            ASSERT(!entry.value.isVar());
    1873             SymbolTableEntry symbolTableEntry = symbolTable->get(NoLockingNecessary, entry.key.get());
     1889
     1890            auto* key = entry.key.get();
     1891            if (scopeType == ScopeType::ClassScope) {
     1892                if (hasPrivateNames) {
     1893                    if (key == propertyNames().builtinNames().privateClassBrandPrivateName()) {
     1894                        ASSERT(entry.value.isConst());
     1895                        continue;
     1896                    }
     1897                    if (key == propertyNames().builtinNames().privateBrandPrivateName()) {
     1898                        ASSERT(entry.value.isConst());
     1899                        continue;
     1900                    }
     1901                } else {
     1902                    ASSERT(key != propertyNames().builtinNames().privateClassBrandPrivateName());
     1903                    ASSERT(key != propertyNames().builtinNames().privateBrandPrivateName());
     1904                }
     1905            }
     1906
     1907#if ASSERT_ENABLED
     1908            SymbolTableEntry symbolTableEntry = symbolTable->get(NoLockingNecessary, key);
    18741909            ASSERT(symbolTableEntry.isNull());
     1910#endif
    18751911
    18761912            // Imported bindings which are not the namespace bindings are not allocated
     
    18811917                continue;
    18821918
    1883             VarKind varKind = lookUpVarKind(entry.key.get(), entry.value);
     1919            VarKind varKind = lookUpVarKind(key, entry.value);
    18841920            VarOffset varOffset;
    18851921            if (varKind == VarKind::Scope) {
     
    18981934
    18991935            SymbolTableEntry newEntry(varOffset, static_cast<unsigned>(entry.value.isConst() ? PropertyAttribute::ReadOnly : PropertyAttribute::None));
    1900             symbolTable->add(NoLockingNecessary, entry.key.get(), newEntry);
     1936            symbolTable->add(NoLockingNecessary, key, newEntry);
    19011937
    19021938            // FIXME: only do this if there is an eval() within a nested scope --- otherwise it isn't needed.
     
    19071943                continue;
    19081944
    1909             auto findResult = privateEnvironment->find(entry.key.get());
     1945            auto findResult = privateEnvironment->find(key);
    19101946
    19111947            if (findResult == privateEnvironment->end())
     
    19441980}
    19451981
    1946 void BytecodeGenerator::pushLexicalScope(VariableEnvironmentNode* node, TDZCheckOptimization tdzCheckOptimization, NestedScopeType nestedScopeType, RegisterID** constantSymbolTableResult, bool shouldInitializeBlockScopedFunctions)
     1982void BytecodeGenerator::pushLexicalScope(VariableEnvironmentNode* node, ScopeType scopeType, TDZCheckOptimization tdzCheckOptimization, NestedScopeType nestedScopeType, RegisterID** constantSymbolTableResult, bool shouldInitializeBlockScopedFunctions)
    19471983{
    19481984    VariableEnvironment& environment = node->lexicalVariables();
    19491985    RegisterID* constantSymbolTableResultTemp = nullptr;
    1950     pushLexicalScopeInternal(environment, tdzCheckOptimization, nestedScopeType, &constantSymbolTableResultTemp, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block);
     1986    pushLexicalScopeInternal(environment, tdzCheckOptimization, nestedScopeType, &constantSymbolTableResultTemp, TDZRequirement::UnderTDZ, scopeType, ScopeRegisterType::Block);
    19511987
    19521988    if (shouldInitializeBlockScopedFunctions)
     
    19722008        break;
    19732009    case ScopeType::LetConstScope:
     2010    case ScopeType::ClassScope:
    19742011        symbolTable->setScopeType(SymbolTable::ScopeType::LexicalScope);
    19752012        break;
     
    19862023    };
    19872024
    1988     bool hasCapturedVariables = instantiateLexicalVariables(environment, symbolTable, scopeRegisterType, lookUpVarKind);
     2025    bool hasCapturedVariables = instantiateLexicalVariables(environment, scopeType, symbolTable, scopeRegisterType, lookUpVarKind);
    19892026
    19902027    RegisterID* newScope = nullptr;
     
    24502487            scope,
    24512488            addConstant(variable.ident()),
    2452             GetPutInfo(resolveMode, variable.offset().isScope() ? LocalClosureVar : resolveType(), InitializationMode::NotInitialization, ecmaMode()),
     2489            GetPutInfo(resolveMode, variable.offset().isScope() ? ResolvedClosureVar : resolveType(), InitializationMode::NotInitialization, ecmaMode()),
    24532490            localScopeDepth(),
    24542491            variable.offset().isScope() ? variable.offset().scopeOffset().offset() : 0);
     
    24772514        if (variable.offset().isScope()) {
    24782515            offset = variable.offset().scopeOffset();
    2479             getPutInfo = GetPutInfo(resolveMode, LocalClosureVar, initializationMode, ecmaMode());
     2516            getPutInfo = GetPutInfo(resolveMode, ResolvedClosureVar, initializationMode, ecmaMode());
    24802517            symbolTableOrScopeDepth = SymbolTableOrScopeDepth::symbolTable(VirtualRegister { variable.symbolTableConstantIndex() });
    24812518        } else {
    2482             ASSERT(resolveType() != LocalClosureVar);
     2519            ASSERT(resolveType() != ResolvedClosureVar);
    24832520            getPutInfo = GetPutInfo(resolveMode, resolveType(), initializationMode, ecmaMode());
    24842521            symbolTableOrScopeDepth = SymbolTableOrScopeDepth::scopeDepth(localScopeDepth());
     
    27612798}
    27622799
    2763 void BytecodeGenerator::emitCreatePrivateBrand(RegisterID* scope, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
     2800void BytecodeGenerator::emitCreatePrivateBrand(const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
    27642801{
    27652802    RefPtr<RegisterID> createPrivateSymbol = moveLinkTimeConstant(nullptr, LinkTimeConstant::createPrivateSymbol);
     
    27712808    Variable privateBrandVar = variable(propertyNames().builtinNames().privateBrandPrivateName());
    27722809
    2773     emitPutToScope(scope, privateBrandVar, newSymbol, DoNotThrowIfNotFound, InitializationMode::ConstInitialization);
     2810    emitPutToScope(scopeRegister(), privateBrandVar, newSymbol, DoNotThrowIfNotFound, InitializationMode::ConstInitialization);
    27742811}
    27752812
     
    27912828RegisterID* BytecodeGenerator::emitGetPrivateBrand(RegisterID* dst, RegisterID* scope, bool isStatic)
    27922829{
    2793     Variable privateBrandVar = isStatic
    2794         ? variable(propertyNames().builtinNames().privateClassBrandPrivateName())
    2795         : variable(propertyNames().builtinNames().privateBrandPrivateName());
    2796     return emitGetFromScope(dst, scope, privateBrandVar, ThrowIfNotFound);
     2830    ASSERT(scope);
     2831    OpGetFromScope::emit(
     2832        this,
     2833        kill(dst),
     2834        scope,
     2835        addConstant(isStatic ? propertyNames().builtinNames().privateClassBrandPrivateName() : propertyNames().builtinNames().privateBrandPrivateName()),
     2836        GetPutInfo(ThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, ecmaMode()),
     2837        0,
     2838        isStatic ? PrivateNameEntry::privateClassBrandOffset : PrivateNameEntry::privateBrandOffset);
     2839    return dst;
    27972840}
    27982841
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r278588 r278591  
    690690        // This doesn't emit expression info. If using this, make sure you shouldn't be emitting text offset.
    691691        void emitProfileType(RegisterID* registerToProfile, ProfileTypeBytecodeFlag);
    692         // These variables are associated with variables in a program. They could be Locals, LocalClosureVar, or ClosureVar.
     692        // These variables are associated with variables in a program. They could be Locals, ResolvedClosureVar, or ClosureVar.
    693693        void emitProfileType(RegisterID* registerToProfile, const Variable&, const JSTextPosition& startDivot, const JSTextPosition& endDivot);
    694694
     
    843843        RegisterID* emitHasPrivateName(RegisterID* dst, RegisterID* base, RegisterID* property);
    844844
    845         void emitCreatePrivateBrand(RegisterID* dst, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd);
     845        void emitCreatePrivateBrand(const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd);
    846846        void emitInstallPrivateBrand(RegisterID* target);
    847847        void emitInstallPrivateClassBrand(RegisterID* target);
     
    11001100        enum class TDZCheckOptimization { Optimize, DoNotOptimize };
    11011101        enum class NestedScopeType { IsNested, IsNotNested };
     1102        enum class ScopeType { CatchScope, LetConstScope, FunctionNameScope, ClassScope };
    11021103    private:
    11031104        enum class TDZRequirement { UnderTDZ, NotUnderTDZ };
    1104         enum class ScopeType { CatchScope, LetConstScope, FunctionNameScope };
    11051105        enum class ScopeRegisterType { Var, Block };
    11061106        void pushLexicalScopeInternal(VariableEnvironment&, TDZCheckOptimization, NestedScopeType, RegisterID** constantSymbolTableResult, TDZRequirement, ScopeType, ScopeRegisterType);
     
    11081108        void popLexicalScopeInternal(VariableEnvironment&);
    11091109        template<typename LookUpVarKindFunctor>
    1110         bool instantiateLexicalVariables(const VariableEnvironment&, SymbolTable*, ScopeRegisterType, LookUpVarKindFunctor);
     1110        bool instantiateLexicalVariables(const VariableEnvironment&, ScopeType, SymbolTable*, ScopeRegisterType, LookUpVarKindFunctor);
    11111111        void emitPrefillStackTDZVariables(const VariableEnvironment&, SymbolTable*);
    11121112        RegisterID* emitGetParentScope(RegisterID* dst, RegisterID* scope);
     
    11301130        bool isSuperCallUsedInInnerArrowFunction();
    11311131        bool isThisUsedInInnerArrowFunction();
    1132         void pushLexicalScope(VariableEnvironmentNode*, TDZCheckOptimization, NestedScopeType = NestedScopeType::IsNotNested, RegisterID** constantSymbolTableResult = nullptr, bool shouldInitializeBlockScopedFunctions = true);
     1132        void pushLexicalScope(VariableEnvironmentNode*, ScopeType, TDZCheckOptimization, NestedScopeType = NestedScopeType::IsNotNested, RegisterID** constantSymbolTableResult = nullptr, bool shouldInitializeBlockScopedFunctions = true);
     1133        void pushClassLexicalScope(VariableEnvironmentNode*);
    11331134        void popLexicalScope(VariableEnvironmentNode*);
    11341135        void prepareLexicalScopeForNextForLoopIteration(VariableEnvironmentNode*, RegisterID* loopSymbolTable);
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r278578 r278591  
    983983            Variable var = generator.variable(identifierName);
    984984            RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
    985 
     985            ASSERT(scope); // Private names are always captured.
    986986            RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
    987987            generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
     
    993993            Variable var = generator.variable(identifierName);
    994994            RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
    995 
     995            ASSERT(scope); // Private names are always captured.
    996996            RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
    997997            generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
     
    10081008            Variable var = generator.variable(identifierName);
    10091009            RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
    1010 
     1010            ASSERT(scope); // Private names are always captured.
    10111011            RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
    10121012            generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
     
    10201020
    10211021        RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
     1022        ASSERT(scope); // Private names are always captured.
    10221023        RefPtr<RegisterID> privateName = generator.newTemporary();
    10231024        generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound);
     
    10481049            Variable var = generator.variable(identifierName);
    10491050            RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
    1050 
     1051            ASSERT(scope); // Private names are always captured.
    10511052            RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
    10521053            generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
     
    10651066            Variable var = generator.variable(identifierName);
    10661067            RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
    1067 
     1068            ASSERT(scope); // Private names are always captured.
    10681069            RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
    10691070            generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
     
    10781079
    10791080        RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
     1081        ASSERT(scope); // Private names are always captured.
    10801082        RefPtr<RegisterID> privateName = generator.newTemporary();
    10811083        generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound);
     
    24182420            Variable var = generator.variable(ident);
    24192421            RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
     2422            ASSERT(scope); // Private names are always captured.
    24202423            RefPtr<RegisterID> privateName = generator.newTemporary();
    24212424            generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound);
     
    24322435            Variable var = generator.variable(ident);
    24332436            RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
    2434 
     2437            ASSERT(scope); // Private names are always captured.
    24352438            RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
    24362439            generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic());
     
    24432446        Variable var = generator.variable(ident);
    24442447        RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
    2445 
     2448        ASSERT(scope); // Private names are always captured.
    24462449        RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
    24472450        generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic());
     
    27212724            Variable var = generator.variable(ident);
    27222725            RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
    2723 
     2726            ASSERT(scope); // Private names are always captured.
    27242727            RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
    27252728            generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic());
     
    27322735        Variable var = generator.variable(ident);
    27332736        RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
    2734 
     2737        ASSERT(scope); // Private names are always captured.
    27352738        RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
    27362739        generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic());
     
    32143217        Variable var = generator.variable(identifier);
    32153218        RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
     3219        ASSERT(scope); // Private names are always captured.
    32163220
    32173221        if (privateTraits.isField()) {
     
    38203824    if (!m_statements)
    38213825        return;
    3822     generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested);
     3826    generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested);
    38233827    m_statements->emitBytecode(generator, dst);
    38243828    generator.popLexicalScope(this);
     
    40334037
    40344038    RegisterID* forLoopSymbolTable = nullptr;
    4035     generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
     4039    generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
    40364040
    40374041    if (m_expr1)
     
    41844188
    41854189    RegisterID* forLoopSymbolTable = nullptr;
    4186     generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
     4190    generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
    41874191
    41884192    if (m_lexpr->isAssignResolveNode())
     
    43534357
    43544358    RegisterID* forLoopSymbolTable = nullptr;
    4355     generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
     4359    generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
    43564360    auto extractor = scopedLambda<void(BytecodeGenerator&, RegisterID*)>([this, dst](BytecodeGenerator& generator, RegisterID* value)
    43574361    {
     
    46874691    RefPtr<RegisterID> r0 = generator.emitNode(m_expr);
    46884692
    4689     generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::DoNotOptimize, BytecodeGenerator::NestedScopeType::IsNested);
     4693    generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::DoNotOptimize, BytecodeGenerator::NestedScopeType::IsNested);
    46904694    m_block->emitBytecodeForBlock(generator, r0.get(), dst);
    46914695    generator.popLexicalScope(this);
     
    51875191
    51885192    if (m_needsLexicalScope)
    5189         generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested);
     5193        generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::ClassScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested);
    51905194
    51915195    bool hasPrivateNames = !!m_lexicalVariables.privateNamesSize();
     
    51955199        generator.pushPrivateAccessNames(m_lexicalVariables.privateNameEnvironment());
    51965200    if (shouldEmitPrivateBrand)
    5197         generator.emitCreatePrivateBrand(generator.scopeRegister(), m_position, m_position, m_position);
     5201        generator.emitCreatePrivateBrand(m_position, m_position, m_position);
    51985202
    51995203    RefPtr<RegisterID> superclass;
Note: See TracChangeset for help on using the changeset viewer.