Diff
Modified: trunk/JSTests/ChangeLog (278590 => 278591)
--- trunk/JSTests/ChangeLog 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/JSTests/ChangeLog 2021-06-08 03:22:27 UTC (rev 278591)
@@ -1,3 +1,26 @@
+2021-06-06 Yusuke Suzuki <[email protected]>
+
+ [JSC] Use ResolvedClosureVar to get brand from scope
+ https://bugs.webkit.org/show_bug.cgi?id=226677
+ rdar://78802869
+
+ Reviewed by Saam Barati.
+
+ * 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):
+
2021-06-07 Alexey Shvayka <[email protected]>
Unreviewed, reland r276592 with a fix for put() override in prototype chain of a JSProxy
Added: trunk/JSTests/stress/private-access-nested-eval.js (0 => 278591)
--- trunk/JSTests/stress/private-access-nested-eval.js (rev 0)
+++ trunk/JSTests/stress/private-access-nested-eval.js 2021-06-08 03:22:27 UTC (rev 278591)
@@ -0,0 +1,33 @@
+function shouldThrow(func, errorMessage) {
+ var errorThrown = false;
+ var error = null;
+ try {
+ func();
+ } catch (e) {
+ errorThrown = true;
+ error = e;
+ }
+ if (!errorThrown)
+ throw new Error('not thrown');
+ if (String(error) !== errorMessage)
+ throw new Error(`bad error: ${String(error)}`);
+}
+
+shouldThrow(() => {
+ class D {
+ #x() {}
+ m() {
+ class C {
+ #yy;
+ #z() {}
+ a() {
+ eval(`this.#x();`);
+ }
+ }
+ let c = new C();
+ c.a();
+ }
+ }
+ let d = new D();
+ d.m();
+}, `TypeError: Cannot access private method or acessor (evaluating 'this.#x')`);
Added: trunk/JSTests/stress/private-access-nested.js (0 => 278591)
--- trunk/JSTests/stress/private-access-nested.js (rev 0)
+++ trunk/JSTests/stress/private-access-nested.js 2021-06-08 03:22:27 UTC (rev 278591)
@@ -0,0 +1,33 @@
+function shouldThrow(func, errorMessage) {
+ var errorThrown = false;
+ var error = null;
+ try {
+ func();
+ } catch (e) {
+ errorThrown = true;
+ error = e;
+ }
+ if (!errorThrown)
+ throw new Error('not thrown');
+ if (String(error) !== errorMessage)
+ throw new Error(`bad error: ${String(error)}`);
+}
+
+shouldThrow(() => {
+ class D {
+ #x() {}
+ m() {
+ class C {
+ #yy;
+ #z() {}
+ a() {
+ this.#x();
+ }
+ }
+ let c = new C();
+ c.a();
+ }
+ }
+ let d = new D();
+ d.m();
+}, `TypeError: Cannot access private method or acessor (evaluating 'this.#x')`);
Modified: trunk/Source/_javascript_Core/ChangeLog (278590 => 278591)
--- trunk/Source/_javascript_Core/ChangeLog 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-06-08 03:22:27 UTC (rev 278591)
@@ -1,3 +1,70 @@
+2021-06-06 Yusuke Suzuki <[email protected]>
+
+ [JSC] Use ResolvedClosureVar to get brand from scope
+ https://bugs.webkit.org/show_bug.cgi?id=226677
+ rdar://78802869
+
+ Reviewed by Saam Barati.
+
+ 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:
+
2021-06-07 Alexey Shvayka <[email protected]>
Unreviewed, reland r276592 with a fix for put() override in prototype chain of a JSProxy
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeGeneratorification.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/bytecode/BytecodeGeneratorification.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeGeneratorification.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -244,7 +244,7 @@
scope, // scope
storage.identifierIndex, // identifier
operand, // value
- GetPutInfo(DoNotThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization, m_bytecodeGenerator.ecmaMode()), // info
+ GetPutInfo(DoNotThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, m_bytecodeGenerator.ecmaMode()), // info
SymbolTableOrScopeDepth::symbolTable(VirtualRegister { m_generatorFrameSymbolTableIndex }), // symbol table constant index
storage.scopeOffset.offset() // scope offset
);
@@ -264,7 +264,7 @@
operand, // dst
scope, // scope
storage.identifierIndex, // identifier
- GetPutInfo(DoNotThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization, m_bytecodeGenerator.ecmaMode()), // info
+ GetPutInfo(DoNotThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, m_bytecodeGenerator.ecmaMode()), // info
0, // local scope depth
storage.scopeOffset.offset() // scope offset
);
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -559,7 +559,7 @@
INITIALIZE_METADATA(OpResolveScope)
const Identifier& ident = identifier(bytecode.m_var);
- RELEASE_ASSERT(bytecode.m_resolveType != LocalClosureVar);
+ RELEASE_ASSERT(bytecode.m_resolveType != ResolvedClosureVar);
ResolveOp op = JSScope::abstractResolve(m_globalObject.get(), bytecode.m_localScopeDepth, scope, ident, Get, bytecode.m_resolveType, InitializationMode::NotInitialization);
RETURN_IF_EXCEPTION(throwScope, false);
@@ -590,7 +590,7 @@
metadata.m_watchpointSet = nullptr;
ASSERT(!isInitialization(bytecode.m_getPutInfo.initializationMode()));
- if (bytecode.m_getPutInfo.resolveType() == LocalClosureVar) {
+ if (bytecode.m_getPutInfo.resolveType() == ResolvedClosureVar) {
metadata.m_getPutInfo = GetPutInfo(bytecode.m_getPutInfo.resolveMode(), ClosureVar, bytecode.m_getPutInfo.initializationMode(), bytecode.m_getPutInfo.ecmaMode());
break;
}
@@ -613,7 +613,7 @@
case op_put_to_scope: {
INITIALIZE_METADATA(OpPutToScope)
- if (bytecode.m_getPutInfo.resolveType() == LocalClosureVar) {
+ if (bytecode.m_getPutInfo.resolveType() == ResolvedClosureVar) {
// Only do watching if the property we're putting to is not anonymous.
if (bytecode.m_var != UINT_MAX) {
SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(bytecode.m_symbolTableOrScopeDepth.symbolTable()));
@@ -1420,7 +1420,7 @@
auto handleGetPutFromScope = [&] (auto& metadata) {
GetPutInfo getPutInfo = metadata.m_getPutInfo;
if (getPutInfo.resolveType() == GlobalVar || getPutInfo.resolveType() == GlobalVarWithVarInjectionChecks
- || getPutInfo.resolveType() == LocalClosureVar || getPutInfo.resolveType() == GlobalLexicalVar || getPutInfo.resolveType() == GlobalLexicalVarWithVarInjectionChecks)
+ || getPutInfo.resolveType() == ResolvedClosureVar || getPutInfo.resolveType() == GlobalLexicalVar || getPutInfo.resolveType() == GlobalLexicalVarWithVarInjectionChecks)
return;
WriteBarrierBase<Structure>& structure = metadata.m_structure;
if (!structure || vm.heap.isMarked(structure.get()))
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -528,7 +528,7 @@
entry.disableWatching(m_vm);
functionSymbolTable->set(NoLockingNecessary, name, entry);
}
- OpPutToScope::emit(this, m_lexicalEnvironmentRegister, UINT_MAX, virtualRegisterForArgumentIncludingThis(1 + i), GetPutInfo(ThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization, ecmaMode), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset());
+ OpPutToScope::emit(this, m_lexicalEnvironmentRegister, UINT_MAX, virtualRegisterForArgumentIncludingThis(1 + i), GetPutInfo(ThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, ecmaMode), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset());
}
// This creates a scoped arguments object and copies the overflow arguments into the
@@ -566,7 +566,7 @@
static_cast<const BindingNode*>(parameters.at(i).first)->boundProperty();
functionSymbolTable->set(NoLockingNecessary, name, SymbolTableEntry(VarOffset(offset)));
- OpPutToScope::emit(this, m_lexicalEnvironmentRegister, addConstant(ident), virtualRegisterForArgumentIncludingThis(1 + i), GetPutInfo(ThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization, ecmaMode), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset());
+ OpPutToScope::emit(this, m_lexicalEnvironmentRegister, addConstant(ident), virtualRegisterForArgumentIncludingThis(1 + i), GetPutInfo(ThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, ecmaMode), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset());
}
}
@@ -842,7 +842,7 @@
}
bool shouldInitializeBlockScopedFunctions = false; // We generate top-level function declarations in ::generate().
- pushLexicalScope(m_scopeNode, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, shouldInitializeBlockScopedFunctions);
+ pushLexicalScope(m_scopeNode, ScopeType::LetConstScope, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, shouldInitializeBlockScopedFunctions);
}
BytecodeGenerator::BytecodeGenerator(VM& vm, EvalNode* evalNode, UnlinkedEvalCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const PrivateNameEnvironment* parentPrivateNameEnvironment)
@@ -907,7 +907,7 @@
}
bool shouldInitializeBlockScopedFunctions = false; // We generate top-level function declarations in ::generate().
- pushLexicalScope(m_scopeNode, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, shouldInitializeBlockScopedFunctions);
+ pushLexicalScope(m_scopeNode, ScopeType::LetConstScope, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, shouldInitializeBlockScopedFunctions);
}
BytecodeGenerator::BytecodeGenerator(VM& vm, ModuleProgramNode* moduleProgramNode, UnlinkedModuleProgramCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const PrivateNameEnvironment*)
@@ -989,7 +989,7 @@
}
VariableEnvironment& lexicalVariables = moduleProgramNode->lexicalVariables();
- instantiateLexicalVariables(lexicalVariables, moduleEnvironmentSymbolTable, ScopeRegisterType::Block, lookUpVarKind);
+ instantiateLexicalVariables(lexicalVariables, ScopeType::LetConstScope, moduleEnvironmentSymbolTable, ScopeRegisterType::Block, lookUpVarKind);
// We keep the symbol table in the constant pool.
RegisterID* constantSymbolTable = nullptr;
@@ -1863,15 +1863,51 @@
}
template<typename LookUpVarKindFunctor>
-bool BytecodeGenerator::instantiateLexicalVariables(const VariableEnvironment& lexicalVariables, SymbolTable* symbolTable, ScopeRegisterType scopeRegisterType, LookUpVarKindFunctor lookUpVarKind)
+bool BytecodeGenerator::instantiateLexicalVariables(const VariableEnvironment& lexicalVariables, ScopeType scopeType, SymbolTable* symbolTable, ScopeRegisterType scopeRegisterType, LookUpVarKindFunctor lookUpVarKind)
{
bool hasCapturedVariables = false;
{
+ bool hasPrivateNames = lexicalVariables.privateNamesSize();
+ // We need to ensure that @privateClassBrand and @privateBrand offsets are 0 and 1 respectively.
+ // To ensure that, we first define them, and later, we filter them out from lexicalVariables.
+ if (scopeType == ScopeType::ClassScope) {
+ if (hasPrivateNames) {
+ hasCapturedVariables = true;
+ VarOffset privateClassBrandOffset = VarOffset(symbolTable->takeNextScopeOffset(NoLockingNecessary));
+ ASSERT(privateClassBrandOffset.rawOffset() == PrivateNameEntry::privateClassBrandOffset);
+ symbolTable->add(NoLockingNecessary, propertyNames().builtinNames().privateClassBrandPrivateName().impl(), SymbolTableEntry { privateClassBrandOffset, static_cast<unsigned>(PropertyAttribute::ReadOnly) });
+
+ VarOffset privateBrandOffset = VarOffset(symbolTable->takeNextScopeOffset(NoLockingNecessary));
+ ASSERT(privateBrandOffset.rawOffset() == PrivateNameEntry::privateBrandOffset);
+ symbolTable->add(NoLockingNecessary, propertyNames().builtinNames().privateBrandPrivateName().impl(), SymbolTableEntry { privateBrandOffset, static_cast<unsigned>(PropertyAttribute::ReadOnly) });
+ }
+ }
+
for (auto& entry : lexicalVariables) {
ASSERT(entry.value.isLet() || entry.value.isConst() || entry.value.isFunction());
ASSERT(!entry.value.isVar());
- SymbolTableEntry symbolTableEntry = symbolTable->get(NoLockingNecessary, entry.key.get());
+
+ auto* key = entry.key.get();
+ if (scopeType == ScopeType::ClassScope) {
+ if (hasPrivateNames) {
+ if (key == propertyNames().builtinNames().privateClassBrandPrivateName()) {
+ ASSERT(entry.value.isConst());
+ continue;
+ }
+ if (key == propertyNames().builtinNames().privateBrandPrivateName()) {
+ ASSERT(entry.value.isConst());
+ continue;
+ }
+ } else {
+ ASSERT(key != propertyNames().builtinNames().privateClassBrandPrivateName());
+ ASSERT(key != propertyNames().builtinNames().privateBrandPrivateName());
+ }
+ }
+
+#if ASSERT_ENABLED
+ SymbolTableEntry symbolTableEntry = symbolTable->get(NoLockingNecessary, key);
ASSERT(symbolTableEntry.isNull());
+#endif
// Imported bindings which are not the namespace bindings are not allocated
// in the module environment as usual variables' way.
@@ -1880,7 +1916,7 @@
if (entry.value.isImported() && !entry.value.isImportedNamespace())
continue;
- VarKind varKind = lookUpVarKind(entry.key.get(), entry.value);
+ VarKind varKind = lookUpVarKind(key, entry.value);
VarOffset varOffset;
if (varKind == VarKind::Scope) {
varOffset = VarOffset(symbolTable->takeNextScopeOffset(NoLockingNecessary));
@@ -1897,7 +1933,7 @@
}
SymbolTableEntry newEntry(varOffset, static_cast<unsigned>(entry.value.isConst() ? PropertyAttribute::ReadOnly : PropertyAttribute::None));
- symbolTable->add(NoLockingNecessary, entry.key.get(), newEntry);
+ symbolTable->add(NoLockingNecessary, key, newEntry);
// FIXME: only do this if there is an eval() within a nested scope --- otherwise it isn't needed.
// https://bugs.webkit.org/show_bug.cgi?id=206663
@@ -1906,7 +1942,7 @@
if (!privateEnvironment)
continue;
- auto findResult = privateEnvironment->find(entry.key.get());
+ auto findResult = privateEnvironment->find(key);
if (findResult == privateEnvironment->end())
continue;
@@ -1943,11 +1979,11 @@
}
}
-void BytecodeGenerator::pushLexicalScope(VariableEnvironmentNode* node, TDZCheckOptimization tdzCheckOptimization, NestedScopeType nestedScopeType, RegisterID** constantSymbolTableResult, bool shouldInitializeBlockScopedFunctions)
+void BytecodeGenerator::pushLexicalScope(VariableEnvironmentNode* node, ScopeType scopeType, TDZCheckOptimization tdzCheckOptimization, NestedScopeType nestedScopeType, RegisterID** constantSymbolTableResult, bool shouldInitializeBlockScopedFunctions)
{
VariableEnvironment& environment = node->lexicalVariables();
RegisterID* constantSymbolTableResultTemp = nullptr;
- pushLexicalScopeInternal(environment, tdzCheckOptimization, nestedScopeType, &constantSymbolTableResultTemp, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block);
+ pushLexicalScopeInternal(environment, tdzCheckOptimization, nestedScopeType, &constantSymbolTableResultTemp, TDZRequirement::UnderTDZ, scopeType, ScopeRegisterType::Block);
if (shouldInitializeBlockScopedFunctions)
initializeBlockScopedFunctions(environment, node->functionStack(), constantSymbolTableResultTemp);
@@ -1971,6 +2007,7 @@
symbolTable->setScopeType(SymbolTable::ScopeType::CatchScope);
break;
case ScopeType::LetConstScope:
+ case ScopeType::ClassScope:
symbolTable->setScopeType(SymbolTable::ScopeType::LexicalScope);
break;
case ScopeType::FunctionNameScope:
@@ -1985,7 +2022,7 @@
return entry.isCaptured() ? VarKind::Scope : VarKind::Stack;
};
- bool hasCapturedVariables = instantiateLexicalVariables(environment, symbolTable, scopeRegisterType, lookUpVarKind);
+ bool hasCapturedVariables = instantiateLexicalVariables(environment, scopeType, symbolTable, scopeRegisterType, lookUpVarKind);
RegisterID* newScope = nullptr;
RegisterID* constantSymbolTable = nullptr;
@@ -2449,7 +2486,7 @@
kill(dst),
scope,
addConstant(variable.ident()),
- GetPutInfo(resolveMode, variable.offset().isScope() ? LocalClosureVar : resolveType(), InitializationMode::NotInitialization, ecmaMode()),
+ GetPutInfo(resolveMode, variable.offset().isScope() ? ResolvedClosureVar : resolveType(), InitializationMode::NotInitialization, ecmaMode()),
localScopeDepth(),
variable.offset().isScope() ? variable.offset().scopeOffset().offset() : 0);
return dst;
@@ -2476,10 +2513,10 @@
ScopeOffset offset;
if (variable.offset().isScope()) {
offset = variable.offset().scopeOffset();
- getPutInfo = GetPutInfo(resolveMode, LocalClosureVar, initializationMode, ecmaMode());
+ getPutInfo = GetPutInfo(resolveMode, ResolvedClosureVar, initializationMode, ecmaMode());
symbolTableOrScopeDepth = SymbolTableOrScopeDepth::symbolTable(VirtualRegister { variable.symbolTableConstantIndex() });
} else {
- ASSERT(resolveType() != LocalClosureVar);
+ ASSERT(resolveType() != ResolvedClosureVar);
getPutInfo = GetPutInfo(resolveMode, resolveType(), initializationMode, ecmaMode());
symbolTableOrScopeDepth = SymbolTableOrScopeDepth::scopeDepth(localScopeDepth());
}
@@ -2760,7 +2797,7 @@
return value;
}
-void BytecodeGenerator::emitCreatePrivateBrand(RegisterID* scope, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
+void BytecodeGenerator::emitCreatePrivateBrand(const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
{
RefPtr<RegisterID> createPrivateSymbol = moveLinkTimeConstant(nullptr, LinkTimeConstant::createPrivateSymbol);
@@ -2770,7 +2807,7 @@
Variable privateBrandVar = variable(propertyNames().builtinNames().privateBrandPrivateName());
- emitPutToScope(scope, privateBrandVar, newSymbol, DoNotThrowIfNotFound, InitializationMode::ConstInitialization);
+ emitPutToScope(scopeRegister(), privateBrandVar, newSymbol, DoNotThrowIfNotFound, InitializationMode::ConstInitialization);
}
void BytecodeGenerator::emitInstallPrivateBrand(RegisterID* target)
@@ -2790,10 +2827,16 @@
RegisterID* BytecodeGenerator::emitGetPrivateBrand(RegisterID* dst, RegisterID* scope, bool isStatic)
{
- Variable privateBrandVar = isStatic
- ? variable(propertyNames().builtinNames().privateClassBrandPrivateName())
- : variable(propertyNames().builtinNames().privateBrandPrivateName());
- return emitGetFromScope(dst, scope, privateBrandVar, ThrowIfNotFound);
+ ASSERT(scope);
+ OpGetFromScope::emit(
+ this,
+ kill(dst),
+ scope,
+ addConstant(isStatic ? propertyNames().builtinNames().privateClassBrandPrivateName() : propertyNames().builtinNames().privateBrandPrivateName()),
+ GetPutInfo(ThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, ecmaMode()),
+ 0,
+ isStatic ? PrivateNameEntry::privateClassBrandOffset : PrivateNameEntry::privateBrandOffset);
+ return dst;
}
RegisterID* BytecodeGenerator::emitPrivateFieldPut(RegisterID* base, RegisterID* property, RegisterID* value)
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (278590 => 278591)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2021-06-08 03:22:27 UTC (rev 278591)
@@ -689,7 +689,7 @@
// This doesn't emit _expression_ info. If using this, make sure you shouldn't be emitting text offset.
void emitProfileType(RegisterID* registerToProfile, ProfileTypeBytecodeFlag);
- // These variables are associated with variables in a program. They could be Locals, LocalClosureVar, or ClosureVar.
+ // These variables are associated with variables in a program. They could be Locals, ResolvedClosureVar, or ClosureVar.
void emitProfileType(RegisterID* registerToProfile, const Variable&, const JSTextPosition& startDivot, const JSTextPosition& endDivot);
void emitProfileType(RegisterID* registerToProfile, ProfileTypeBytecodeFlag, const JSTextPosition& startDivot, const JSTextPosition& endDivot);
@@ -842,7 +842,7 @@
RegisterID* emitGetPrivateName(RegisterID* dst, RegisterID* base, RegisterID* property);
RegisterID* emitHasPrivateName(RegisterID* dst, RegisterID* base, RegisterID* property);
- void emitCreatePrivateBrand(RegisterID* dst, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd);
+ void emitCreatePrivateBrand(const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd);
void emitInstallPrivateBrand(RegisterID* target);
void emitInstallPrivateClassBrand(RegisterID* target);
@@ -1099,15 +1099,15 @@
enum class TDZCheckOptimization { Optimize, DoNotOptimize };
enum class NestedScopeType { IsNested, IsNotNested };
+ enum class ScopeType { CatchScope, LetConstScope, FunctionNameScope, ClassScope };
private:
enum class TDZRequirement { UnderTDZ, NotUnderTDZ };
- enum class ScopeType { CatchScope, LetConstScope, FunctionNameScope };
enum class ScopeRegisterType { Var, Block };
void pushLexicalScopeInternal(VariableEnvironment&, TDZCheckOptimization, NestedScopeType, RegisterID** constantSymbolTableResult, TDZRequirement, ScopeType, ScopeRegisterType);
void initializeBlockScopedFunctions(VariableEnvironment&, FunctionStack&, RegisterID* constantSymbolTable);
void popLexicalScopeInternal(VariableEnvironment&);
template<typename LookUpVarKindFunctor>
- bool instantiateLexicalVariables(const VariableEnvironment&, SymbolTable*, ScopeRegisterType, LookUpVarKindFunctor);
+ bool instantiateLexicalVariables(const VariableEnvironment&, ScopeType, SymbolTable*, ScopeRegisterType, LookUpVarKindFunctor);
void emitPrefillStackTDZVariables(const VariableEnvironment&, SymbolTable*);
RegisterID* emitGetParentScope(RegisterID* dst, RegisterID* scope);
void emitPushFunctionNameScope(const Identifier& property, RegisterID* value, bool isCaptured);
@@ -1129,7 +1129,8 @@
bool isSuperUsedInInnerArrowFunction();
bool isSuperCallUsedInInnerArrowFunction();
bool isThisUsedInInnerArrowFunction();
- void pushLexicalScope(VariableEnvironmentNode*, TDZCheckOptimization, NestedScopeType = NestedScopeType::IsNotNested, RegisterID** constantSymbolTableResult = nullptr, bool shouldInitializeBlockScopedFunctions = true);
+ void pushLexicalScope(VariableEnvironmentNode*, ScopeType, TDZCheckOptimization, NestedScopeType = NestedScopeType::IsNotNested, RegisterID** constantSymbolTableResult = nullptr, bool shouldInitializeBlockScopedFunctions = true);
+ void pushClassLexicalScope(VariableEnvironmentNode*);
void popLexicalScope(VariableEnvironmentNode*);
void prepareLexicalScopeForNextForLoopIteration(VariableEnvironmentNode*, RegisterID* loopSymbolTable);
int labelScopeDepth() const;
Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -982,7 +982,7 @@
if (privateTraits.isMethod()) {
Variable var = generator.variable(identifierName);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
-
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
@@ -992,7 +992,7 @@
if (privateTraits.isGetter()) {
Variable var = generator.variable(identifierName);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
-
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
@@ -1007,7 +1007,7 @@
// We need to perform brand check to follow the spec
Variable var = generator.variable(identifierName);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
-
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
generator.emitThrowTypeError("Trying to access an undefined private getter");
@@ -1019,6 +1019,7 @@
ASSERT_WITH_MESSAGE(!var.local(), "Private Field names must be stored in captured variables");
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateName = generator.newTemporary();
generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound);
return generator.emitGetPrivateName(dst, base, privateName.get());
@@ -1047,7 +1048,7 @@
if (privateTraits.isSetter()) {
Variable var = generator.variable(identifierName);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
-
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
@@ -1064,7 +1065,7 @@
if (privateTraits.isGetter() || privateTraits.isMethod()) {
Variable var = generator.variable(identifierName);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
-
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
generator.emitCheckPrivateBrand(base, privateBrandSymbol.get(), privateTraits.isStatic());
@@ -1077,6 +1078,7 @@
ASSERT_WITH_MESSAGE(!var.local(), "Private Field names must be stored in captured variables");
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateName = generator.newTemporary();
generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound);
return generator.emitPrivateFieldPut(base, privateName.get(), value);
@@ -2417,6 +2419,7 @@
if (privateTraits.isField()) {
Variable var = generator.variable(ident);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateName = generator.newTemporary();
generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound);
@@ -2431,7 +2434,7 @@
if (privateTraits.isMethod()) {
Variable var = generator.variable(ident);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
-
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic());
@@ -2442,7 +2445,7 @@
Variable var = generator.variable(ident);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
-
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic());
@@ -2720,7 +2723,7 @@
if (privateTraits.isMethod()) {
Variable var = generator.variable(ident);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
-
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic());
@@ -2731,7 +2734,7 @@
Variable var = generator.variable(ident);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
-
+ ASSERT(scope); // Private names are always captured.
RefPtr<RegisterID> privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get(), privateTraits.isStatic());
generator.emitCheckPrivateBrand(base.get(), privateBrandSymbol.get(), privateTraits.isStatic());
@@ -3213,6 +3216,7 @@
auto privateTraits = generator.getPrivateTraits(identifier);
Variable var = generator.variable(identifier);
RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
+ ASSERT(scope); // Private names are always captured.
if (privateTraits.isField()) {
RefPtr<RegisterID> privateName = generator.emitGetFromScope(generator.newTemporary(), scope.get(), var, DoNotThrowIfNotFound);
@@ -3819,7 +3823,7 @@
{
if (!m_statements)
return;
- generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested);
+ generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested);
m_statements->emitBytecode(generator, dst);
generator.popLexicalScope(this);
}
@@ -4032,7 +4036,7 @@
Ref<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
RegisterID* forLoopSymbolTable = nullptr;
- generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
+ generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
if (m_expr1)
generator.emitNode(generator.ignoredResult(), m_expr1);
@@ -4183,7 +4187,7 @@
Ref<Label> end = generator.newLabel();
RegisterID* forLoopSymbolTable = nullptr;
- generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
+ generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
if (m_lexpr->isAssignResolveNode())
generator.emitNode(generator.ignoredResult(), m_lexpr);
@@ -4352,7 +4356,7 @@
generator.emitLoad(dst, jsUndefined());
RegisterID* forLoopSymbolTable = nullptr;
- generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
+ generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
auto extractor = scopedLambda<void(BytecodeGenerator&, RegisterID*)>([this, dst](BytecodeGenerator& generator, RegisterID* value)
{
if (m_lexpr->isResolveNode()) {
@@ -4686,7 +4690,7 @@
RefPtr<RegisterID> r0 = generator.emitNode(m_expr);
- generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::DoNotOptimize, BytecodeGenerator::NestedScopeType::IsNested);
+ generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::LetConstScope, BytecodeGenerator::TDZCheckOptimization::DoNotOptimize, BytecodeGenerator::NestedScopeType::IsNested);
m_block->emitBytecodeForBlock(generator, r0.get(), dst);
generator.popLexicalScope(this);
@@ -5186,7 +5190,7 @@
StrictModeScope strictModeScope(generator);
if (m_needsLexicalScope)
- generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested);
+ generator.pushLexicalScope(this, BytecodeGenerator::ScopeType::ClassScope, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested);
bool hasPrivateNames = !!m_lexicalVariables.privateNamesSize();
bool shouldEmitPrivateBrand = m_lexicalVariables.hasInstancePrivateMethodOrAccessor();
@@ -5194,7 +5198,7 @@
if (hasPrivateNames)
generator.pushPrivateAccessNames(m_lexicalVariables.privateNameEnvironment());
if (shouldEmitPrivateBrand)
- generator.emitCreatePrivateBrand(generator.scopeRegister(), m_position, m_position, m_position);
+ generator.emitCreatePrivateBrand(m_position, m_position, m_position);
RefPtr<RegisterID> superclass;
if (m_classHeritage) {
Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -4246,7 +4246,7 @@
case GlobalProperty:
case GlobalLexicalVar:
case ClosureVar:
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ModuleVar:
return false;
@@ -7643,7 +7643,7 @@
case ModuleVar:
lexicalEnvironment = metadata.m_lexicalEnvironment.get();
break;
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ClosureVar:
case ClosureVarWithVarInjectionChecks:
symbolTable = metadata.m_symbolTable.get();
@@ -7690,7 +7690,7 @@
set(bytecode.m_dst, weakJSConstant(lexicalEnvironment));
break;
}
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ClosureVar:
case ClosureVarWithVarInjectionChecks: {
Node* localBase = get(bytecode.m_scope);
@@ -7871,7 +7871,7 @@
set(bytecode.m_dst, value);
break;
}
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ClosureVar:
case ClosureVarWithVarInjectionChecks: {
Node* scopeNode = get(bytecode.m_scope);
@@ -7929,7 +7929,7 @@
ConcurrentJSLocker locker(m_inlineStackTop->m_profiledBlock->m_lock);
getPutInfo = metadata.m_getPutInfo;
resolveType = getPutInfo.resolveType();
- if (resolveType == GlobalVar || resolveType == GlobalVarWithVarInjectionChecks || resolveType == LocalClosureVar || resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks)
+ if (resolveType == GlobalVar || resolveType == GlobalVarWithVarInjectionChecks || resolveType == ResolvedClosureVar || resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks)
watchpoints = metadata.m_watchpointSet;
else if (resolveType != UnresolvedProperty && resolveType != UnresolvedPropertyWithVarInjectionChecks)
structure = metadata.m_structure.get();
@@ -7995,7 +7995,7 @@
addToGraph(Phantom, get(bytecode.m_scope));
break;
}
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ClosureVar:
case ClosureVarWithVarInjectionChecks: {
Node* scopeNode = get(bytecode.m_scope);
Modified: trunk/Source/_javascript_Core/jit/JIT.h (278590 => 278591)
--- trunk/Source/_javascript_Core/jit/JIT.h 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/jit/JIT.h 2021-06-08 03:22:27 UTC (rev 278591)
@@ -840,8 +840,8 @@
static constexpr bool thunkIsUsedForOpGetFromScope(ResolveType resolveType)
{
// GlobalVar because it is more efficient to emit inline than use a thunk.
- // LocalClosureVar and ModuleVar because we don't use these types with op_get_from_scope.
- return !(resolveType == GlobalVar || resolveType == LocalClosureVar || resolveType == ModuleVar);
+ // ResolvedClosureVar and ModuleVar because we don't use these types with op_get_from_scope.
+ return !(resolveType == GlobalVar || resolveType == ResolvedClosureVar || resolveType == ModuleVar);
}
#define DECLARE_GET_FROM_SCOPE_GENERATOR(resolveType) \
@@ -854,8 +854,8 @@
static constexpr bool thunkIsUsedForOpResolveScope(ResolveType resolveType)
{
// ModuleVar because it is more efficient to emit inline than use a thunk.
- // LocalClosureVar because we don't use these types with op_resolve_scope.
- return !(resolveType == LocalClosureVar || resolveType == ModuleVar);
+ // ResolvedClosureVar because we don't use these types with op_resolve_scope.
+ return !(resolveType == ResolvedClosureVar || resolveType == ModuleVar);
}
#define DECLARE_RESOLVE_SCOPE_GENERATOR(resolveType) \
Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/jit/JITOperations.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -3045,11 +3045,11 @@
// ModuleVar does not keep the scope register value alive in DFG.
ASSERT(getPutInfo.resolveType() != ModuleVar);
- if (getPutInfo.resolveType() == LocalClosureVar) {
+ if (getPutInfo.resolveType() == ResolvedClosureVar) {
JSLexicalEnvironment* environment = jsCast<JSLexicalEnvironment*>(scope);
environment->variableAt(ScopeOffset(metadata.m_operand)).set(vm, environment, value);
if (WatchpointSet* set = metadata.m_watchpointSet)
- set->touch(vm, "Executed op_put_scope<LocalClosureVar>");
+ set->touch(vm, "Executed op_put_scope<ResolvedClosureVar>");
return;
}
Modified: trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -1705,7 +1705,7 @@
case Dynamic:
addSlowCase(jump());
break;
- case LocalClosureVar:
+ case ResolvedClosureVar:
case UnresolvedProperty:
case UnresolvedPropertyWithVarInjectionChecks:
RELEASE_ASSERT_NOT_REACHED();
@@ -1885,7 +1885,7 @@
case Dynamic:
slowCase.append(jump());
break;
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ModuleVar:
case UnresolvedProperty:
case UnresolvedPropertyWithVarInjectionChecks:
@@ -2093,7 +2093,7 @@
case Dynamic:
addSlowCase(jump());
break;
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ModuleVar:
case UnresolvedProperty:
case UnresolvedPropertyWithVarInjectionChecks:
@@ -2307,7 +2307,7 @@
case Dynamic:
slowCase.append(jump());
break;
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ModuleVar:
case UnresolvedProperty:
case UnresolvedPropertyWithVarInjectionChecks:
@@ -2520,7 +2520,7 @@
emitWriteBarrier(constantScope, value, ShouldFilterValue);
break;
}
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ClosureVar:
case ClosureVarWithVarInjectionChecks:
emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
Modified: trunk/Source/_javascript_Core/jit/JITPropertyAccess32_64.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/jit/JITPropertyAccess32_64.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/jit/JITPropertyAccess32_64.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -1014,7 +1014,7 @@
case Dynamic:
addSlowCase(jump());
break;
- case LocalClosureVar:
+ case ResolvedClosureVar:
case UnresolvedProperty:
case UnresolvedPropertyWithVarInjectionChecks:
RELEASE_ASSERT_NOT_REACHED();
@@ -1153,7 +1153,7 @@
addSlowCase(jump());
break;
case ModuleVar:
- case LocalClosureVar:
+ case ResolvedClosureVar:
case UnresolvedProperty:
case UnresolvedPropertyWithVarInjectionChecks:
RELEASE_ASSERT_NOT_REACHED();
@@ -1299,7 +1299,7 @@
emitPutGlobalVariable(bitwise_cast<JSValue*>(*operandSlot), value, metadata.m_watchpointSet);
break;
}
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ClosureVar:
case ClosureVarWithVarInjectionChecks:
emitWriteBarrier(scope, value, ShouldFilterValue);
Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -2178,7 +2178,7 @@
const Identifier& ident = codeBlock->identifier(bytecode.m_var);
JSObject* scope = jsCast<JSObject*>(getNonConstantOperand(callFrame, bytecode.m_scope));
JSValue value = getOperand(callFrame, bytecode.m_value);
- if (metadata.m_getPutInfo.resolveType() == LocalClosureVar) {
+ if (metadata.m_getPutInfo.resolveType() == ResolvedClosureVar) {
JSLexicalEnvironment* environment = jsCast<JSLexicalEnvironment*>(scope);
environment->variableAt(ScopeOffset(metadata.m_operand)).set(vm, environment, value);
@@ -2186,7 +2186,7 @@
// to have already changed the value of the variable. Otherwise we might watch and constant-fold
// to the Undefined value from before the assignment.
if (metadata.m_watchpointSet)
- metadata.m_watchpointSet->touch(vm, "Executed op_put_scope<LocalClosureVar>");
+ metadata.m_watchpointSet->touch(vm, "Executed op_put_scope<ResolvedClosureVar>");
LLINT_END();
}
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (278590 => 278591)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2021-06-08 03:22:27 UTC (rev 278591)
@@ -592,7 +592,7 @@
const GlobalVar = constexpr GlobalVar
const GlobalLexicalVar = constexpr GlobalLexicalVar
const ClosureVar = constexpr ClosureVar
-const LocalClosureVar = constexpr LocalClosureVar
+const ResolvedClosureVar = constexpr ResolvedClosureVar
const ModuleVar = constexpr ModuleVar
const GlobalPropertyWithVarInjectionChecks = constexpr GlobalPropertyWithVarInjectionChecks
const GlobalVarWithVarInjectionChecks = constexpr GlobalVarWithVarInjectionChecks
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm (278590 => 278591)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm 2021-06-08 03:22:27 UTC (rev 278591)
@@ -2582,7 +2582,7 @@
storei t3, JSLexicalEnvironment_variables + PayloadOffset[t0, t1, 8]
end
- macro putLocalClosureVar()
+ macro putResolvedClosureVar()
get(m_value, t1)
loadConstantOrVariable(size, t1, t2, t3)
loadp OpPutToScope::Metadata::m_watchpointSet[t5], t1
@@ -2609,10 +2609,10 @@
loadi OpPutToScope::Metadata::m_getPutInfo + GetPutInfo::m_operand[t5], t0
andi ResolveTypeMask, t0
-#pLocalClosureVar:
- bineq t0, LocalClosureVar, .pGlobalProperty
+#pResolvedClosureVar:
+ bineq t0, ResolvedClosureVar, .pGlobalProperty
loadVariable(get, m_scope, t2, t1, t0)
- putLocalClosureVar()
+ putResolvedClosureVar()
writeBarrierOnOperands(size, get, m_scope, m_value)
dispatch()
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm (278590 => 278591)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm 2021-06-08 03:22:27 UTC (rev 278591)
@@ -2710,7 +2710,7 @@
storeq t2, JSLexicalEnvironment_variables[t0, t1, 8]
end
- macro putLocalClosureVar()
+ macro putResolvedClosureVar()
get(m_value, t1)
loadConstantOrVariable(size, t1, t2)
loadp OpPutToScope::Metadata::m_watchpointSet[t5], t3
@@ -2736,10 +2736,10 @@
loadi OpPutToScope::Metadata::m_getPutInfo + GetPutInfo::m_operand[t5], t0
andi ResolveTypeMask, t0
-#pLocalClosureVar:
- bineq t0, LocalClosureVar, .pGlobalProperty
+#pResolvedClosureVar:
+ bineq t0, ResolvedClosureVar, .pGlobalProperty
loadVariable(get, m_scope, t0)
- putLocalClosureVar()
+ putResolvedClosureVar()
writeBarrierOnOperands(size, get, m_scope, m_value)
dispatch()
Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (278590 => 278591)
--- trunk/Source/_javascript_Core/parser/Parser.cpp 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp 2021-06-08 03:22:27 UTC (rev 278591)
@@ -3146,12 +3146,21 @@
info.endOffset = tokenLocation().endOffset - 1;
consumeOrFail(CLOSEBRACE, "Expected a closing '}' after a class body");
- if (declaresPrivateMethod || declaresPrivateAccessor) {
- Identifier privateBrandIdentifier = m_vm.propertyNames->builtinNames().privateBrandPrivateName();
- DeclarationResultMask declarationResult = classScope->declareLexicalVariable(&privateBrandIdentifier, true);
- ASSERT_UNUSED(declarationResult, declarationResult == DeclarationResult::Valid);
- classScope->useVariable(&privateBrandIdentifier, false);
- classScope->addClosedVariableCandidateUnconditionally(privateBrandIdentifier.impl());
+ if (declaresPrivateMethod || declaresPrivateAccessor || declaresStaticPrivateMethod || declaresStaticPrivateAccessor) {
+ {
+ Identifier privateBrandIdentifier = m_vm.propertyNames->builtinNames().privateBrandPrivateName();
+ DeclarationResultMask declarationResult = classScope->declareLexicalVariable(&privateBrandIdentifier, true);
+ ASSERT_UNUSED(declarationResult, declarationResult == DeclarationResult::Valid);
+ classScope->useVariable(&privateBrandIdentifier, false);
+ classScope->addClosedVariableCandidateUnconditionally(privateBrandIdentifier.impl());
+ }
+ {
+ Identifier privateClassBrandIdentifier = m_vm.propertyNames->builtinNames().privateClassBrandPrivateName();
+ DeclarationResultMask declarationResult = classScope->declareLexicalVariable(&privateClassBrandIdentifier, true);
+ ASSERT_UNUSED(declarationResult, declarationResult == DeclarationResult::Valid);
+ classScope->useVariable(&privateClassBrandIdentifier, false);
+ classScope->addClosedVariableCandidateUnconditionally(privateClassBrandIdentifier.impl());
+ }
}
if constexpr (std::is_same_v<TreeBuilder, ASTBuilder>) {
@@ -3159,14 +3168,6 @@
classElements->setHasPrivateAccessors(declaresPrivateAccessor || declaresStaticPrivateAccessor);
}
- if (declaresStaticPrivateMethod || declaresPrivateAccessor) {
- Identifier privateClassBrandIdentifier = m_vm.propertyNames->builtinNames().privateClassBrandPrivateName();
- DeclarationResultMask declarationResult = classScope->declareLexicalVariable(&privateClassBrandIdentifier, true);
- ASSERT_UNUSED(declarationResult, declarationResult == DeclarationResult::Valid);
- classScope->useVariable(&privateClassBrandIdentifier, false);
- classScope->addClosedVariableCandidateUnconditionally(privateClassBrandIdentifier.impl());
- }
-
if (Options::usePrivateClassFields()) {
// Fail if there are no parent private name scopes and any used-but-undeclared private names.
semanticFailIfFalse(copyUndeclaredPrivateNamesToOuterScope(), "Cannot reference undeclared private names");
Modified: trunk/Source/_javascript_Core/parser/VariableEnvironment.h (278590 => 278591)
--- trunk/Source/_javascript_Core/parser/VariableEnvironment.h 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/parser/VariableEnvironment.h 2021-06-08 03:22:27 UTC (rev 278591)
@@ -101,6 +101,9 @@
struct PrivateNameEntry {
friend class CachedPrivateNameEntry;
+ static constexpr unsigned privateClassBrandOffset = 0;
+ static constexpr unsigned privateBrandOffset = 1;
+
public:
PrivateNameEntry(uint16_t traits = 0) { m_bits = traits; }
Modified: trunk/Source/_javascript_Core/runtime/GetPutInfo.h (278590 => 278591)
--- trunk/Source/_javascript_Core/runtime/GetPutInfo.h 2021-06-08 02:25:49 UTC (rev 278590)
+++ trunk/Source/_javascript_Core/runtime/GetPutInfo.h 2021-06-08 03:22:27 UTC (rev 278591)
@@ -44,7 +44,7 @@
v(GlobalVar) \
v(GlobalLexicalVar) \
v(ClosureVar) \
- v(LocalClosureVar) \
+ v(ResolvedClosureVar) \
v(ModuleVar) \
v(GlobalPropertyWithVarInjectionChecks) \
v(GlobalVarWithVarInjectionChecks) \
@@ -60,7 +60,7 @@
GlobalVar,
GlobalLexicalVar,
ClosureVar,
- LocalClosureVar,
+ ResolvedClosureVar,
ModuleVar,
// Ditto, but at least one intervening scope used non-strict eval, which
@@ -102,7 +102,7 @@
"GlobalVar",
"GlobalLexicalVar",
"ClosureVar",
- "LocalClosureVar",
+ "ResolvedClosureVar",
"ModuleVar",
"GlobalPropertyWithVarInjectionChecks",
"GlobalVarWithVarInjectionChecks",
@@ -151,7 +151,7 @@
case GlobalLexicalVar:
return GlobalLexicalVarWithVarInjectionChecks;
case ClosureVar:
- case LocalClosureVar:
+ case ResolvedClosureVar:
return ClosureVarWithVarInjectionChecks;
case UnresolvedProperty:
return UnresolvedPropertyWithVarInjectionChecks;
@@ -176,7 +176,7 @@
case GlobalVar:
case GlobalLexicalVar:
case ClosureVar:
- case LocalClosureVar:
+ case ResolvedClosureVar:
case ModuleVar:
case UnresolvedProperty:
return false;