Changeset 278591 in webkit
- Timestamp:
- Jun 7, 2021, 8:22:27 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r278589 r278591 1 2021-06-06 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Use ResolvedClosureVar to get brand from scope 4 https://bugs.webkit.org/show_bug.cgi?id=226677 5 rdar://78802869 6 7 Reviewed by Saam Barati. 8 9 * stress/private-access-nested-eval.js: Added. 10 (shouldThrow): 11 (shouldThrow.prototype.x): 12 (shouldThrow.prototype.m.C.prototype.z): 13 (shouldThrow.prototype.m.C.prototype.a): 14 (shouldThrow.prototype.m.C): 15 (shouldThrow.prototype.m): 16 * stress/private-access-nested.js: Added. 17 (shouldThrow): 18 (shouldThrow.prototype.x): 19 (shouldThrow.prototype.m.C.prototype.z): 20 (shouldThrow.prototype.m.C.prototype.a): 21 (shouldThrow.prototype.m.C): 22 (shouldThrow.prototype.m): 23 1 24 2021-06-07 Alexey Shvayka <shvaikalesh@gmail.com> 2 25 -
trunk/Source/JavaScriptCore/ChangeLog
r278589 r278591 1 2021-06-06 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Use ResolvedClosureVar to get brand from scope 4 https://bugs.webkit.org/show_bug.cgi?id=226677 5 rdar://78802869 6 7 Reviewed by Saam Barati. 8 9 Private brand lookup is doing wrong way to get scope. 10 11 1. op_resolve_scope with private name (e.g. #x) 12 2. then, doing op_get_from_scope with (1)'s scope with different name (e.g. @privateBrand) 13 14 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 15 starts with the current scope-register. As a result, private-brand lookup is broken right now. Let's see the buggy case. 16 17 class D { 18 #x() {} 19 m() { 20 class C { 21 #yy; 22 #z() { } 23 a() { 24 this.#x(); // <===== This point. 25 } 26 } 27 let c = new C(); 28 c.a(); 29 } 30 } 31 32 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 33 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 34 C's class-scope in get_from_scope. And this offset is different from D's class-scope's privateBrand. 35 36 Only allowed case for the above usage is ResolvedClosureVar. And generatorification uses it too. In this patch, 37 38 1. We ensure that class-scope (with private name) must have @privateBrand and @privateClassBrand with offset 1 and 0. 39 2. Use ResolvedClosureVar with the above pre-defined offset 40 41 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 42 with the given scope with the compiled offset. 43 44 * bytecompiler/BytecodeGenerator.cpp: 45 (JSC::BytecodeGenerator::BytecodeGenerator): 46 (JSC::BytecodeGenerator::instantiateLexicalVariables): 47 (JSC::BytecodeGenerator::pushLexicalScope): 48 (JSC::BytecodeGenerator::pushLexicalScopeInternal): 49 (JSC::BytecodeGenerator::emitCreatePrivateBrand): 50 (JSC::BytecodeGenerator::emitGetPrivateBrand): 51 * bytecompiler/BytecodeGenerator.h: 52 * bytecompiler/NodesCodegen.cpp: 53 (JSC::BaseDotNode::emitGetPropertyValue): 54 (JSC::BaseDotNode::emitPutProperty): 55 (JSC::PostfixNode::emitDot): 56 (JSC::PrefixNode::emitDot): 57 (JSC::InNode::emitBytecode): 58 (JSC::BlockNode::emitBytecode): 59 (JSC::ForNode::emitBytecode): 60 (JSC::ForInNode::emitBytecode): 61 (JSC::ForOfNode::emitBytecode): 62 (JSC::SwitchNode::emitBytecode): 63 (JSC::ClassExprNode::emitBytecode): 64 * parser/Parser.cpp: 65 (JSC::Parser<LexerType>::parseClass): 66 * parser/VariableEnvironment.h: 67 1 68 2021-06-07 Alexey Shvayka <shvaikalesh@gmail.com> 2 69 -
trunk/Source/JavaScriptCore/bytecode/BytecodeGeneratorification.cpp
r278340 r278591 245 245 storage.identifierIndex, // identifier 246 246 operand, // value 247 GetPutInfo(DoNotThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization, m_bytecodeGenerator.ecmaMode()), // info247 GetPutInfo(DoNotThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, m_bytecodeGenerator.ecmaMode()), // info 248 248 SymbolTableOrScopeDepth::symbolTable(VirtualRegister { m_generatorFrameSymbolTableIndex }), // symbol table constant index 249 249 storage.scopeOffset.offset() // scope offset … … 265 265 scope, // scope 266 266 storage.identifierIndex, // identifier 267 GetPutInfo(DoNotThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization, m_bytecodeGenerator.ecmaMode()), // info267 GetPutInfo(DoNotThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, m_bytecodeGenerator.ecmaMode()), // info 268 268 0, // local scope depth 269 269 storage.scopeOffset.offset() // scope offset -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r278425 r278591 560 560 561 561 const Identifier& ident = identifier(bytecode.m_var); 562 RELEASE_ASSERT(bytecode.m_resolveType != LocalClosureVar);562 RELEASE_ASSERT(bytecode.m_resolveType != ResolvedClosureVar); 563 563 564 564 ResolveOp op = JSScope::abstractResolve(m_globalObject.get(), bytecode.m_localScopeDepth, scope, ident, Get, bytecode.m_resolveType, InitializationMode::NotInitialization); … … 591 591 592 592 ASSERT(!isInitialization(bytecode.m_getPutInfo.initializationMode())); 593 if (bytecode.m_getPutInfo.resolveType() == LocalClosureVar) {593 if (bytecode.m_getPutInfo.resolveType() == ResolvedClosureVar) { 594 594 metadata.m_getPutInfo = GetPutInfo(bytecode.m_getPutInfo.resolveMode(), ClosureVar, bytecode.m_getPutInfo.initializationMode(), bytecode.m_getPutInfo.ecmaMode()); 595 595 break; … … 614 614 INITIALIZE_METADATA(OpPutToScope) 615 615 616 if (bytecode.m_getPutInfo.resolveType() == LocalClosureVar) {616 if (bytecode.m_getPutInfo.resolveType() == ResolvedClosureVar) { 617 617 // Only do watching if the property we're putting to is not anonymous. 618 618 if (bytecode.m_var != UINT_MAX) { … … 1421 1421 GetPutInfo getPutInfo = metadata.m_getPutInfo; 1422 1422 if (getPutInfo.resolveType() == GlobalVar || getPutInfo.resolveType() == GlobalVarWithVarInjectionChecks 1423 || getPutInfo.resolveType() == LocalClosureVar || getPutInfo.resolveType() == GlobalLexicalVar || getPutInfo.resolveType() == GlobalLexicalVarWithVarInjectionChecks)1423 || getPutInfo.resolveType() == ResolvedClosureVar || getPutInfo.resolveType() == GlobalLexicalVar || getPutInfo.resolveType() == GlobalLexicalVarWithVarInjectionChecks) 1424 1424 return; 1425 1425 WriteBarrierBase<Structure>& structure = metadata.m_structure; -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r278588 r278591 529 529 functionSymbolTable->set(NoLockingNecessary, name, entry); 530 530 } 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()); 532 532 } 533 533 … … 567 567 functionSymbolTable->set(NoLockingNecessary, name, SymbolTableEntry(VarOffset(offset))); 568 568 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()); 570 570 } 571 571 } … … 843 843 844 844 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); 846 846 } 847 847 … … 908 908 909 909 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); 911 911 } 912 912 … … 990 990 991 991 VariableEnvironment& lexicalVariables = moduleProgramNode->lexicalVariables(); 992 instantiateLexicalVariables(lexicalVariables, moduleEnvironmentSymbolTable, ScopeRegisterType::Block, lookUpVarKind);992 instantiateLexicalVariables(lexicalVariables, ScopeType::LetConstScope, moduleEnvironmentSymbolTable, ScopeRegisterType::Block, lookUpVarKind); 993 993 994 994 // We keep the symbol table in the constant pool. … … 1864 1864 1865 1865 template<typename LookUpVarKindFunctor> 1866 bool BytecodeGenerator::instantiateLexicalVariables(const VariableEnvironment& lexicalVariables, S ymbolTable* symbolTable, ScopeRegisterType scopeRegisterType, LookUpVarKindFunctor lookUpVarKind)1866 bool BytecodeGenerator::instantiateLexicalVariables(const VariableEnvironment& lexicalVariables, ScopeType scopeType, SymbolTable* symbolTable, ScopeRegisterType scopeRegisterType, LookUpVarKindFunctor lookUpVarKind) 1867 1867 { 1868 1868 bool hasCapturedVariables = false; 1869 1869 { 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 1870 1886 for (auto& entry : lexicalVariables) { 1871 1887 ASSERT(entry.value.isLet() || entry.value.isConst() || entry.value.isFunction()); 1872 1888 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); 1874 1909 ASSERT(symbolTableEntry.isNull()); 1910 #endif 1875 1911 1876 1912 // Imported bindings which are not the namespace bindings are not allocated … … 1881 1917 continue; 1882 1918 1883 VarKind varKind = lookUpVarKind( entry.key.get(), entry.value);1919 VarKind varKind = lookUpVarKind(key, entry.value); 1884 1920 VarOffset varOffset; 1885 1921 if (varKind == VarKind::Scope) { … … 1898 1934 1899 1935 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); 1901 1937 1902 1938 // FIXME: only do this if there is an eval() within a nested scope --- otherwise it isn't needed. … … 1907 1943 continue; 1908 1944 1909 auto findResult = privateEnvironment->find( entry.key.get());1945 auto findResult = privateEnvironment->find(key); 1910 1946 1911 1947 if (findResult == privateEnvironment->end()) … … 1944 1980 } 1945 1981 1946 void BytecodeGenerator::pushLexicalScope(VariableEnvironmentNode* node, TDZCheckOptimization tdzCheckOptimization, NestedScopeType nestedScopeType, RegisterID** constantSymbolTableResult, bool shouldInitializeBlockScopedFunctions)1982 void BytecodeGenerator::pushLexicalScope(VariableEnvironmentNode* node, ScopeType scopeType, TDZCheckOptimization tdzCheckOptimization, NestedScopeType nestedScopeType, RegisterID** constantSymbolTableResult, bool shouldInitializeBlockScopedFunctions) 1947 1983 { 1948 1984 VariableEnvironment& environment = node->lexicalVariables(); 1949 1985 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); 1951 1987 1952 1988 if (shouldInitializeBlockScopedFunctions) … … 1972 2008 break; 1973 2009 case ScopeType::LetConstScope: 2010 case ScopeType::ClassScope: 1974 2011 symbolTable->setScopeType(SymbolTable::ScopeType::LexicalScope); 1975 2012 break; … … 1986 2023 }; 1987 2024 1988 bool hasCapturedVariables = instantiateLexicalVariables(environment, s ymbolTable, scopeRegisterType, lookUpVarKind);2025 bool hasCapturedVariables = instantiateLexicalVariables(environment, scopeType, symbolTable, scopeRegisterType, lookUpVarKind); 1989 2026 1990 2027 RegisterID* newScope = nullptr; … … 2450 2487 scope, 2451 2488 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()), 2453 2490 localScopeDepth(), 2454 2491 variable.offset().isScope() ? variable.offset().scopeOffset().offset() : 0); … … 2477 2514 if (variable.offset().isScope()) { 2478 2515 offset = variable.offset().scopeOffset(); 2479 getPutInfo = GetPutInfo(resolveMode, LocalClosureVar, initializationMode, ecmaMode());2516 getPutInfo = GetPutInfo(resolveMode, ResolvedClosureVar, initializationMode, ecmaMode()); 2480 2517 symbolTableOrScopeDepth = SymbolTableOrScopeDepth::symbolTable(VirtualRegister { variable.symbolTableConstantIndex() }); 2481 2518 } else { 2482 ASSERT(resolveType() != LocalClosureVar);2519 ASSERT(resolveType() != ResolvedClosureVar); 2483 2520 getPutInfo = GetPutInfo(resolveMode, resolveType(), initializationMode, ecmaMode()); 2484 2521 symbolTableOrScopeDepth = SymbolTableOrScopeDepth::scopeDepth(localScopeDepth()); … … 2761 2798 } 2762 2799 2763 void BytecodeGenerator::emitCreatePrivateBrand( RegisterID* scope,const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)2800 void BytecodeGenerator::emitCreatePrivateBrand(const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd) 2764 2801 { 2765 2802 RefPtr<RegisterID> createPrivateSymbol = moveLinkTimeConstant(nullptr, LinkTimeConstant::createPrivateSymbol); … … 2771 2808 Variable privateBrandVar = variable(propertyNames().builtinNames().privateBrandPrivateName()); 2772 2809 2773 emitPutToScope(scope , privateBrandVar, newSymbol, DoNotThrowIfNotFound, InitializationMode::ConstInitialization);2810 emitPutToScope(scopeRegister(), privateBrandVar, newSymbol, DoNotThrowIfNotFound, InitializationMode::ConstInitialization); 2774 2811 } 2775 2812 … … 2791 2828 RegisterID* BytecodeGenerator::emitGetPrivateBrand(RegisterID* dst, RegisterID* scope, bool isStatic) 2792 2829 { 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; 2797 2840 } 2798 2841 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r278588 r278591 690 690 // This doesn't emit expression info. If using this, make sure you shouldn't be emitting text offset. 691 691 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. 693 693 void emitProfileType(RegisterID* registerToProfile, const Variable&, const JSTextPosition& startDivot, const JSTextPosition& endDivot); 694 694 … … 843 843 RegisterID* emitHasPrivateName(RegisterID* dst, RegisterID* base, RegisterID* property); 844 844 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); 846 846 void emitInstallPrivateBrand(RegisterID* target); 847 847 void emitInstallPrivateClassBrand(RegisterID* target); … … 1100 1100 enum class TDZCheckOptimization { Optimize, DoNotOptimize }; 1101 1101 enum class NestedScopeType { IsNested, IsNotNested }; 1102 enum class ScopeType { CatchScope, LetConstScope, FunctionNameScope, ClassScope }; 1102 1103 private: 1103 1104 enum class TDZRequirement { UnderTDZ, NotUnderTDZ }; 1104 enum class ScopeType { CatchScope, LetConstScope, FunctionNameScope };1105 1105 enum class ScopeRegisterType { Var, Block }; 1106 1106 void pushLexicalScopeInternal(VariableEnvironment&, TDZCheckOptimization, NestedScopeType, RegisterID** constantSymbolTableResult, TDZRequirement, ScopeType, ScopeRegisterType); … … 1108 1108 void popLexicalScopeInternal(VariableEnvironment&); 1109 1109 template<typename LookUpVarKindFunctor> 1110 bool instantiateLexicalVariables(const VariableEnvironment&, S ymbolTable*, ScopeRegisterType, LookUpVarKindFunctor);1110 bool instantiateLexicalVariables(const VariableEnvironment&, ScopeType, SymbolTable*, ScopeRegisterType, LookUpVarKindFunctor); 1111 1111 void emitPrefillStackTDZVariables(const VariableEnvironment&, SymbolTable*); 1112 1112 RegisterID* emitGetParentScope(RegisterID* dst, RegisterID* scope); … … 1130 1130 bool isSuperCallUsedInInnerArrowFunction(); 1131 1131 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*); 1133 1134 void popLexicalScope(VariableEnvironmentNode*); 1134 1135 void prepareLexicalScopeForNextForLoopIteration(VariableEnvironmentNode*, RegisterID* loopSymbolTable); -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r278578 r278591 983 983 Variable var = generator.variable(identifierName); 984 984 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 985 985 ASSERT(scope); // Private names are always captured. 986 986 RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic()); 987 987 generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic()); … … 993 993 Variable var = generator.variable(identifierName); 994 994 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 995 995 ASSERT(scope); // Private names are always captured. 996 996 RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic()); 997 997 generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic()); … … 1008 1008 Variable var = generator.variable(identifierName); 1009 1009 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 1010 1010 ASSERT(scope); // Private names are always captured. 1011 1011 RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic()); 1012 1012 generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic()); … … 1020 1020 1021 1021 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 1022 ASSERT(scope); // Private names are always captured. 1022 1023 RefPtr<RegisterID> privateName = generator.newTemporary(); 1023 1024 generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound); … … 1048 1049 Variable var = generator.variable(identifierName); 1049 1050 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 1050 1051 ASSERT(scope); // Private names are always captured. 1051 1052 RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic()); 1052 1053 generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic()); … … 1065 1066 Variable var = generator.variable(identifierName); 1066 1067 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 1067 1068 ASSERT(scope); // Private names are always captured. 1068 1069 RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic()); 1069 1070 generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic()); … … 1078 1079 1079 1080 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 1081 ASSERT(scope); // Private names are always captured. 1080 1082 RefPtr<RegisterID> privateName = generator.newTemporary(); 1081 1083 generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound); … … 2418 2420 Variable var = generator.variable(ident); 2419 2421 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 2422 ASSERT(scope); // Private names are always captured. 2420 2423 RefPtr<RegisterID> privateName = generator.newTemporary(); 2421 2424 generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound); … … 2432 2435 Variable var = generator.variable(ident); 2433 2436 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 2434 2437 ASSERT(scope); // Private names are always captured. 2435 2438 RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic()); 2436 2439 generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic()); … … 2443 2446 Variable var = generator.variable(ident); 2444 2447 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 2445 2448 ASSERT(scope); // Private names are always captured. 2446 2449 RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic()); 2447 2450 generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic()); … … 2721 2724 Variable var = generator.variable(ident); 2722 2725 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 2723 2726 ASSERT(scope); // Private names are always captured. 2724 2727 RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic()); 2725 2728 generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic()); … … 2732 2735 Variable var = generator.variable(ident); 2733 2736 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 2734 2737 ASSERT(scope); // Private names are always captured. 2735 2738 RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic()); 2736 2739 generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic()); … … 3214 3217 Variable var = generator.variable(identifier); 3215 3218 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 3219 ASSERT(scope); // Private names are always captured. 3216 3220 3217 3221 if (privateTraits.isField()) { … … 3820 3824 if (!m_statements) 3821 3825 return; 3822 generator.pushLexicalScope(this, BytecodeGenerator:: TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested);3826 generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested); 3823 3827 m_statements->emitBytecode(generator, dst); 3824 3828 generator.popLexicalScope(this); … … 4033 4037 4034 4038 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); 4036 4040 4037 4041 if (m_expr1) … … 4184 4188 4185 4189 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); 4187 4191 4188 4192 if (m_lexpr->isAssignResolveNode()) … … 4353 4357 4354 4358 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); 4356 4360 auto extractor = scopedLambda<void(BytecodeGenerator&, RegisterID*)>([this, dst](BytecodeGenerator& generator, RegisterID* value) 4357 4361 { … … 4687 4691 RefPtr<RegisterID> r0 = generator.emitNode(m_expr); 4688 4692 4689 generator.pushLexicalScope(this, BytecodeGenerator:: TDZCheckOptimization::DoNotOptimize, BytecodeGenerator::NestedScopeType::IsNested);4693 generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::DoNotOptimize, BytecodeGenerator::NestedScopeType::IsNested); 4690 4694 m_block->emitBytecodeForBlock(generator, r0.get(), dst); 4691 4695 generator.popLexicalScope(this); … … 5187 5191 5188 5192 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); 5190 5194 5191 5195 bool hasPrivateNames = !!m_lexicalVariables.privateNamesSize(); … … 5195 5199 generator.pushPrivateAccessNames(m_lexicalVariables.privateNameEnvironment()); 5196 5200 if (shouldEmitPrivateBrand) 5197 generator.emitCreatePrivateBrand( generator.scopeRegister(),m_position, m_position, m_position);5201 generator.emitCreatePrivateBrand(m_position, m_position, m_position); 5198 5202 5199 5203 RefPtr<RegisterID> superclass; -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r278462 r278591 4247 4247 case GlobalLexicalVar: 4248 4248 case ClosureVar: 4249 case LocalClosureVar:4249 case ResolvedClosureVar: 4250 4250 case ModuleVar: 4251 4251 return false; … … 7644 7644 lexicalEnvironment = metadata.m_lexicalEnvironment.get(); 7645 7645 break; 7646 case LocalClosureVar:7646 case ResolvedClosureVar: 7647 7647 case ClosureVar: 7648 7648 case ClosureVarWithVarInjectionChecks: … … 7691 7691 break; 7692 7692 } 7693 case LocalClosureVar:7693 case ResolvedClosureVar: 7694 7694 case ClosureVar: 7695 7695 case ClosureVarWithVarInjectionChecks: { … … 7872 7872 break; 7873 7873 } 7874 case LocalClosureVar:7874 case ResolvedClosureVar: 7875 7875 case ClosureVar: 7876 7876 case ClosureVarWithVarInjectionChecks: { … … 7930 7930 getPutInfo = metadata.m_getPutInfo; 7931 7931 resolveType = getPutInfo.resolveType(); 7932 if (resolveType == GlobalVar || resolveType == GlobalVarWithVarInjectionChecks || resolveType == LocalClosureVar || resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks)7932 if (resolveType == GlobalVar || resolveType == GlobalVarWithVarInjectionChecks || resolveType == ResolvedClosureVar || resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks) 7933 7933 watchpoints = metadata.m_watchpointSet; 7934 7934 else if (resolveType != UnresolvedProperty && resolveType != UnresolvedPropertyWithVarInjectionChecks) … … 7996 7996 break; 7997 7997 } 7998 case LocalClosureVar:7998 case ResolvedClosureVar: 7999 7999 case ClosureVar: 8000 8000 case ClosureVarWithVarInjectionChecks: { -
trunk/Source/JavaScriptCore/jit/JIT.h
r278576 r278591 841 841 { 842 842 // GlobalVar because it is more efficient to emit inline than use a thunk. 843 // LocalClosureVar and ModuleVar because we don't use these types with op_get_from_scope.844 return !(resolveType == GlobalVar || resolveType == LocalClosureVar || resolveType == ModuleVar);843 // ResolvedClosureVar and ModuleVar because we don't use these types with op_get_from_scope. 844 return !(resolveType == GlobalVar || resolveType == ResolvedClosureVar || resolveType == ModuleVar); 845 845 } 846 846 … … 855 855 { 856 856 // ModuleVar because it is more efficient to emit inline than use a thunk. 857 // LocalClosureVar because we don't use these types with op_resolve_scope.858 return !(resolveType == LocalClosureVar || resolveType == ModuleVar);857 // ResolvedClosureVar because we don't use these types with op_resolve_scope. 858 return !(resolveType == ResolvedClosureVar || resolveType == ModuleVar); 859 859 } 860 860 -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r278445 r278591 3046 3046 ASSERT(getPutInfo.resolveType() != ModuleVar); 3047 3047 3048 if (getPutInfo.resolveType() == LocalClosureVar) {3048 if (getPutInfo.resolveType() == ResolvedClosureVar) { 3049 3049 JSLexicalEnvironment* environment = jsCast<JSLexicalEnvironment*>(scope); 3050 3050 environment->variableAt(ScopeOffset(metadata.m_operand)).set(vm, environment, value); 3051 3051 if (WatchpointSet* set = metadata.m_watchpointSet) 3052 set->touch(vm, "Executed op_put_scope< LocalClosureVar>");3052 set->touch(vm, "Executed op_put_scope<ResolvedClosureVar>"); 3053 3053 return; 3054 3054 } -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp
r278445 r278591 1706 1706 addSlowCase(jump()); 1707 1707 break; 1708 case LocalClosureVar:1708 case ResolvedClosureVar: 1709 1709 case UnresolvedProperty: 1710 1710 case UnresolvedPropertyWithVarInjectionChecks: … … 1886 1886 slowCase.append(jump()); 1887 1887 break; 1888 case LocalClosureVar:1888 case ResolvedClosureVar: 1889 1889 case ModuleVar: 1890 1890 case UnresolvedProperty: … … 2094 2094 addSlowCase(jump()); 2095 2095 break; 2096 case LocalClosureVar:2096 case ResolvedClosureVar: 2097 2097 case ModuleVar: 2098 2098 case UnresolvedProperty: … … 2308 2308 slowCase.append(jump()); 2309 2309 break; 2310 case LocalClosureVar:2310 case ResolvedClosureVar: 2311 2311 case ModuleVar: 2312 2312 case UnresolvedProperty: … … 2521 2521 break; 2522 2522 } 2523 case LocalClosureVar:2523 case ResolvedClosureVar: 2524 2524 case ClosureVar: 2525 2525 case ClosureVarWithVarInjectionChecks: -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
r278445 r278591 1015 1015 addSlowCase(jump()); 1016 1016 break; 1017 case LocalClosureVar:1017 case ResolvedClosureVar: 1018 1018 case UnresolvedProperty: 1019 1019 case UnresolvedPropertyWithVarInjectionChecks: … … 1154 1154 break; 1155 1155 case ModuleVar: 1156 case LocalClosureVar:1156 case ResolvedClosureVar: 1157 1157 case UnresolvedProperty: 1158 1158 case UnresolvedPropertyWithVarInjectionChecks: … … 1300 1300 break; 1301 1301 } 1302 case LocalClosureVar:1302 case ResolvedClosureVar: 1303 1303 case ClosureVar: 1304 1304 case ClosureVarWithVarInjectionChecks: -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r278445 r278591 2179 2179 JSObject* scope = jsCast<JSObject*>(getNonConstantOperand(callFrame, bytecode.m_scope)); 2180 2180 JSValue value = getOperand(callFrame, bytecode.m_value); 2181 if (metadata.m_getPutInfo.resolveType() == LocalClosureVar) {2181 if (metadata.m_getPutInfo.resolveType() == ResolvedClosureVar) { 2182 2182 JSLexicalEnvironment* environment = jsCast<JSLexicalEnvironment*>(scope); 2183 2183 environment->variableAt(ScopeOffset(metadata.m_operand)).set(vm, environment, value); … … 2187 2187 // to the Undefined value from before the assignment. 2188 2188 if (metadata.m_watchpointSet) 2189 metadata.m_watchpointSet->touch(vm, "Executed op_put_scope< LocalClosureVar>");2189 metadata.m_watchpointSet->touch(vm, "Executed op_put_scope<ResolvedClosureVar>"); 2190 2190 LLINT_END(); 2191 2191 } -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r278445 r278591 593 593 const GlobalLexicalVar = constexpr GlobalLexicalVar 594 594 const ClosureVar = constexpr ClosureVar 595 const LocalClosureVar = constexpr LocalClosureVar595 const ResolvedClosureVar = constexpr ResolvedClosureVar 596 596 const ModuleVar = constexpr ModuleVar 597 597 const GlobalPropertyWithVarInjectionChecks = constexpr GlobalPropertyWithVarInjectionChecks -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
r278157 r278591 2583 2583 end 2584 2584 2585 macro put LocalClosureVar()2585 macro putResolvedClosureVar() 2586 2586 get(m_value, t1) 2587 2587 loadConstantOrVariable(size, t1, t2, t3) … … 2610 2610 andi ResolveTypeMask, t0 2611 2611 2612 #p LocalClosureVar:2613 bineq t0, LocalClosureVar, .pGlobalProperty2612 #pResolvedClosureVar: 2613 bineq t0, ResolvedClosureVar, .pGlobalProperty 2614 2614 loadVariable(get, m_scope, t2, t1, t0) 2615 put LocalClosureVar()2615 putResolvedClosureVar() 2616 2616 writeBarrierOnOperands(size, get, m_scope, m_value) 2617 2617 dispatch() -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r275995 r278591 2711 2711 end 2712 2712 2713 macro put LocalClosureVar()2713 macro putResolvedClosureVar() 2714 2714 get(m_value, t1) 2715 2715 loadConstantOrVariable(size, t1, t2) … … 2737 2737 andi ResolveTypeMask, t0 2738 2738 2739 #p LocalClosureVar:2740 bineq t0, LocalClosureVar, .pGlobalProperty2739 #pResolvedClosureVar: 2740 bineq t0, ResolvedClosureVar, .pGlobalProperty 2741 2741 loadVariable(get, m_scope, t0) 2742 put LocalClosureVar()2742 putResolvedClosureVar() 2743 2743 writeBarrierOnOperands(size, get, m_scope, m_value) 2744 2744 dispatch() -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r278588 r278591 3147 3147 consumeOrFail(CLOSEBRACE, "Expected a closing '}' after a class body"); 3148 3148 3149 if (declaresPrivateMethod || declaresPrivateAccessor) { 3150 Identifier privateBrandIdentifier = m_vm.propertyNames->builtinNames().privateBrandPrivateName(); 3151 DeclarationResultMask declarationResult = classScope->declareLexicalVariable(&privateBrandIdentifier, true); 3152 ASSERT_UNUSED(declarationResult, declarationResult == DeclarationResult::Valid); 3153 classScope->useVariable(&privateBrandIdentifier, false); 3154 classScope->addClosedVariableCandidateUnconditionally(privateBrandIdentifier.impl()); 3149 if (declaresPrivateMethod || declaresPrivateAccessor || declaresStaticPrivateMethod || declaresStaticPrivateAccessor) { 3150 { 3151 Identifier privateBrandIdentifier = m_vm.propertyNames->builtinNames().privateBrandPrivateName(); 3152 DeclarationResultMask declarationResult = classScope->declareLexicalVariable(&privateBrandIdentifier, true); 3153 ASSERT_UNUSED(declarationResult, declarationResult == DeclarationResult::Valid); 3154 classScope->useVariable(&privateBrandIdentifier, false); 3155 classScope->addClosedVariableCandidateUnconditionally(privateBrandIdentifier.impl()); 3156 } 3157 { 3158 Identifier privateClassBrandIdentifier = m_vm.propertyNames->builtinNames().privateClassBrandPrivateName(); 3159 DeclarationResultMask declarationResult = classScope->declareLexicalVariable(&privateClassBrandIdentifier, true); 3160 ASSERT_UNUSED(declarationResult, declarationResult == DeclarationResult::Valid); 3161 classScope->useVariable(&privateClassBrandIdentifier, false); 3162 classScope->addClosedVariableCandidateUnconditionally(privateClassBrandIdentifier.impl()); 3163 } 3155 3164 } 3156 3165 … … 3158 3167 if (classElements) 3159 3168 classElements->setHasPrivateAccessors(declaresPrivateAccessor || declaresStaticPrivateAccessor); 3160 }3161 3162 if (declaresStaticPrivateMethod || declaresPrivateAccessor) {3163 Identifier privateClassBrandIdentifier = m_vm.propertyNames->builtinNames().privateClassBrandPrivateName();3164 DeclarationResultMask declarationResult = classScope->declareLexicalVariable(&privateClassBrandIdentifier, true);3165 ASSERT_UNUSED(declarationResult, declarationResult == DeclarationResult::Valid);3166 classScope->useVariable(&privateClassBrandIdentifier, false);3167 classScope->addClosedVariableCandidateUnconditionally(privateClassBrandIdentifier.impl());3168 3169 } 3169 3170 -
trunk/Source/JavaScriptCore/parser/VariableEnvironment.h
r277926 r278591 102 102 friend class CachedPrivateNameEntry; 103 103 104 static constexpr unsigned privateClassBrandOffset = 0; 105 static constexpr unsigned privateBrandOffset = 1; 106 104 107 public: 105 108 PrivateNameEntry(uint16_t traits = 0) { m_bits = traits; } -
trunk/Source/JavaScriptCore/runtime/GetPutInfo.h
r278029 r278591 45 45 v(GlobalLexicalVar) \ 46 46 v(ClosureVar) \ 47 v( LocalClosureVar) \47 v(ResolvedClosureVar) \ 48 48 v(ModuleVar) \ 49 49 v(GlobalPropertyWithVarInjectionChecks) \ … … 61 61 GlobalLexicalVar, 62 62 ClosureVar, 63 LocalClosureVar,63 ResolvedClosureVar, 64 64 ModuleVar, 65 65 … … 103 103 "GlobalLexicalVar", 104 104 "ClosureVar", 105 " LocalClosureVar",105 "ResolvedClosureVar", 106 106 "ModuleVar", 107 107 "GlobalPropertyWithVarInjectionChecks", … … 152 152 return GlobalLexicalVarWithVarInjectionChecks; 153 153 case ClosureVar: 154 case LocalClosureVar:154 case ResolvedClosureVar: 155 155 return ClosureVarWithVarInjectionChecks; 156 156 case UnresolvedProperty: … … 177 177 case GlobalLexicalVar: 178 178 case ClosureVar: 179 case LocalClosureVar:179 case ResolvedClosureVar: 180 180 case ModuleVar: 181 181 case UnresolvedProperty:
Note:
See TracChangeset
for help on using the changeset viewer.