Fix defects

* using references for auto variables
* embed identifier operations for non-generic block infos

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
HyukWoo Park 2024-01-02 16:22:04 +09:00 committed by Patrick Kim
commit a4afdefbf2
4 changed files with 19 additions and 17 deletions

View file

@ -676,13 +676,14 @@ void InterpretedCodeBlock::computeVariables()
} else {
m_blockInfos[i] = BlockInfo::genericBlockInfo(false, m_blockInfos[i]->identifiers().size());
}
ASSERT(!m_blockInfos[i]->identifiers().size());
} else {
m_blockInfos[i]->setCanAllocateEnvironmentOnStack(false);
m_blockInfos[i]->setShouldAllocateEnvironment(m_blockInfos[i]->identifiers().size());
}
for (size_t j = 0; j < m_blockInfos[i]->identifiers().size(); j++) {
m_blockInfos[i]->identifiers()[j].m_indexForIndexedStorage = SIZE_MAX;
m_blockInfos[i]->identifiers()[j].m_needToAllocateOnStack = false;
for (size_t j = 0; j < m_blockInfos[i]->identifiers().size(); j++) {
m_blockInfos[i]->identifiers()[j].m_indexForIndexedStorage = SIZE_MAX;
m_blockInfos[i]->identifiers()[j].m_needToAllocateOnStack = false;
}
}
}
} else {
@ -762,13 +763,14 @@ void InterpretedCodeBlock::computeVariables()
} else {
m_blockInfos[i] = BlockInfo::genericBlockInfo(false, m_blockInfos[i]->identifiers().size());
}
ASSERT(!m_blockInfos[i]->identifiers().size());
} else {
m_blockInfos[i]->setCanAllocateEnvironmentOnStack(false);
m_blockInfos[i]->setShouldAllocateEnvironment(m_blockInfos[i]->identifiers().size());
}
for (size_t j = 0; j < m_blockInfos[i]->identifiers().size(); j++) {
m_blockInfos[i]->identifiers()[j].m_indexForIndexedStorage = SIZE_MAX;
m_blockInfos[i]->identifiers()[j].m_needToAllocateOnStack = false;
for (size_t j = 0; j < m_blockInfos[i]->identifiers().size(); j++) {
m_blockInfos[i]->identifiers()[j].m_indexForIndexedStorage = SIZE_MAX;
m_blockInfos[i]->identifiers()[j].m_needToAllocateOnStack = false;
}
}
}
} else {

View file

@ -5115,7 +5115,7 @@ public:
this->expect(LeftBrace);
this->parseDirectivePrologues(builder, body);
auto previousLabelSet = this->context->labelSet;
auto previousLabelSet = std::move(this->context->labelSet);
bool previousInIteration = this->context->inIteration;
bool previousInSwitch = this->context->inSwitch;
bool previousInFunctionBody = this->context->inFunctionBody;
@ -5150,7 +5150,7 @@ public:
this->context->allowLexicalDeclaration = oldAllowLexicalDeclaration;
this->nameDeclaredCallback = oldNameCallback;
this->context->labelSet = previousLabelSet;
this->context->labelSet = std::move(previousLabelSet);
this->context->inIteration = previousInIteration;
this->context->inSwitch = previousInSwitch;
this->context->inFunctionBody = previousInFunctionBody;
@ -6967,7 +6967,7 @@ public:
params->appendChild(this->finalize(node, builder.createExpressionStatementNode(init)));
}
auto previousLabelSet = this->context->labelSet;
auto previousLabelSet = std::move(this->context->labelSet);
bool previousInIteration = this->context->inIteration;
bool previousInSwitch = this->context->inSwitch;
bool previousInFunctionBody = this->context->inFunctionBody;
@ -6996,7 +6996,7 @@ public:
this->context->strict = previousStrict;
this->context->allowYield = previousAllowYield;
this->context->labelSet = previousLabelSet;
this->context->labelSet = std::move(previousLabelSet);
this->context->inIteration = previousInIteration;
this->context->inSwitch = previousInSwitch;
this->context->inFunctionBody = previousInFunctionBody;
@ -7022,7 +7022,7 @@ public:
MetaNode nodeStart = this->createNode();
StatementContainer* container = builder.createStatementContainer();
auto previousLabelSet = this->context->labelSet;
auto previousLabelSet = std::move(this->context->labelSet);
bool previousInIteration = this->context->inIteration;
bool previousInSwitch = this->context->inSwitch;
bool previousInFunctionBody = this->context->inFunctionBody;
@ -7053,7 +7053,7 @@ public:
this->context->strict = previousStrict;
this->context->allowYield = previousAllowYield;
this->context->labelSet = previousLabelSet;
this->context->labelSet = std::move(previousLabelSet);
this->context->inIteration = previousInIteration;
this->context->inSwitch = previousInSwitch;
this->context->inFunctionBody = previousInFunctionBody;

View file

@ -216,7 +216,7 @@ Value AsyncGeneratorObject::asyncGeneratorResolve(ExecutionState& state, AsyncGe
auto next = queue[0];
queue.erase(0);
// Let promiseCapability be next.[[Capability]].
auto promiseCapability = next.m_capability;
auto& promiseCapability = next.m_capability;
// Let iteratorResult be ! CreateIterResultObject(value, done).
Value iteratorResult = IteratorObject::createIterResultObject(state, value, done);
// Perform ! Call(promiseCapability.[[Resolve]], undefined, « iteratorResult »).
@ -239,7 +239,7 @@ Value AsyncGeneratorObject::asyncGeneratorReject(ExecutionState& state, AsyncGen
auto next = queue[0];
queue.erase(0);
// Let promiseCapability be next.[[Capability]].
auto promiseCapability = next.m_capability;
auto& promiseCapability = next.m_capability;
// Perform ! Call(promiseCapability.[[Reject]], undefined, « exception »).
Object::call(state, promiseCapability.m_rejectFunction, Value(), 1, &exception);
// Perform ! AsyncGeneratorResumeNext(generator).

View file

@ -149,7 +149,7 @@ void RegExpObject::internalInit(ExecutionState& state, String* source, Option op
m_source = source->length() ? source : defaultRegExpString;
m_source = escapeSlashInPattern(m_source);
auto entry = getCacheEntryAndCompileIfNeeded(state, m_source, this->option());
auto& entry = getCacheEntryAndCompileIfNeeded(state, m_source, this->option());
if (entry.m_yarrError) {
m_source = previousSource;
setOptionValueForGC(previousOptions);