+2017-08-08 Robin Morisset <rmorisset@apple.com>
+
+ Make JSC_validateExceptionChecks=1 succeed on JSTests/slowMicrobenchmarks/spread-small-array.js.
+ https://bugs.webkit.org/show_bug.cgi?id=175347
+
+ Reviewed by Saam Barati.
+
+ This is done by making finishCreation explicitely check for exceptions after setConstantRegister and setConstantIdentifiersSetRegisters.
+ I chose to have this check replace the boolean returned previously by these functions for readability. The performance impact should be
+ negligible considering how much more finishCreation does.
+ This fix then caused another issue to appear as it was now clear that finishCreation can throw. And since it is called by ProgramCodeBlock::create(),
+ FunctionCodeBlock::create() and friends, that are in turn called by ScriptExecutable::newCodeBlockFor, this last function also required a few tweaks.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::finishCreation):
+ (JSC::CodeBlock::setConstantIdentifierSetRegisters):
+ (JSC::CodeBlock::setConstantRegisters):
+ * bytecode/CodeBlock.h:
+ * runtime/ScriptExecutable.cpp:
+ (JSC::ScriptExecutable::newCodeBlockFor):
+
2017-08-08 Michael Catanzaro <mcatanzaro@igalia.com>
Unreviewed, fix Ubuntu LTS build
JSScope* scope)
{
Base::finishCreation(vm);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
if (vm.typeProfiler() || vm.controlFlowProfiler())
vm.functionHasExecutedCache()->removeUnexecutedRange(ownerExecutable->sourceID(), ownerExecutable->typeProfilingStartOffset(), ownerExecutable->typeProfilingEndOffset());
- if (!setConstantRegisters(unlinkedCodeBlock->constantRegisters(), unlinkedCodeBlock->constantsSourceCodeRepresentation()))
- return false;
+ setConstantRegisters(unlinkedCodeBlock->constantRegisters(), unlinkedCodeBlock->constantsSourceCodeRepresentation());
+ RETURN_IF_EXCEPTION(throwScope, false);
- if (!setConstantIdentifierSetRegisters(vm, unlinkedCodeBlock->constantIdentifierSets()))
- return false;
+ setConstantIdentifierSetRegisters(vm, unlinkedCodeBlock->constantIdentifierSets());
+ RETURN_IF_EXCEPTION(throwScope, false);
if (unlinkedCodeBlock->usesGlobalObject())
m_constantRegisters[unlinkedCodeBlock->globalObjectRegister().toConstantIndex()].set(*m_vm, this, m_globalObject.get());
#endif // ENABLE(JIT)
}
-bool CodeBlock::setConstantIdentifierSetRegisters(VM& vm, const Vector<ConstantIndentifierSetEntry>& constants)
+void CodeBlock::setConstantIdentifierSetRegisters(VM& vm, const Vector<ConstantIndentifierSetEntry>& constants)
{
auto scope = DECLARE_THROW_SCOPE(vm);
JSGlobalObject* globalObject = m_globalObject.get();
for (const auto& entry : constants) {
Structure* setStructure = globalObject->setStructure();
- RETURN_IF_EXCEPTION(scope, false);
+ RETURN_IF_EXCEPTION(scope, void());
JSSet* jsSet = JSSet::create(exec, vm, setStructure);
- RETURN_IF_EXCEPTION(scope, false);
+ RETURN_IF_EXCEPTION(scope, void());
const IdentifierSet& set = entry.first;
for (auto setEntry : set) {
JSString* jsString = jsOwnedString(&vm, setEntry.get());
jsSet->add(exec, jsString);
- RETURN_IF_EXCEPTION(scope, false);
+ RETURN_IF_EXCEPTION(scope, void());
}
m_constantRegisters[entry.second].set(vm, this, jsSet);
}
-
- scope.release();
- return true;
}
-bool CodeBlock::setConstantRegisters(const Vector<WriteBarrier<Unknown>>& constants, const Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation)
+void CodeBlock::setConstantRegisters(const Vector<WriteBarrier<Unknown>>& constants, const Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation)
{
auto scope = DECLARE_THROW_SCOPE(*m_vm);
JSGlobalObject* globalObject = m_globalObject.get();
constant = clone;
} else if (isTemplateRegistryKey(*m_vm, constant)) {
auto* templateObject = globalObject->templateRegistry().getTemplateObject(exec, jsCast<JSTemplateRegistryKey*>(constant));
- RETURN_IF_EXCEPTION(scope, false);
+ RETURN_IF_EXCEPTION(scope, void());
constant = templateObject;
}
}
}
m_constantsSourceCodeRepresentation = constantsSourceCodeRepresentation;
-
- return true;
}
void CodeBlock::setAlternative(VM& vm, CodeBlock* alternative)
auto codeBlock = EvalCodeBlock::create(vm,
executable, executable->m_unlinkedEvalCodeBlock.get(), scope,
executable->source().provider());
+ ASSERT(throwScope.exception() || codeBlock);
if (!codeBlock) {
exception = throwException(
exec, throwScope,
auto codeBlock = ProgramCodeBlock::create(vm,
executable, executable->m_unlinkedProgramCodeBlock.get(), scope,
executable->source().provider(), startColumn());
+ ASSERT(throwScope.exception() || codeBlock);
if (!codeBlock) {
exception = throwException(
exec, throwScope,
auto codeBlock = ModuleProgramCodeBlock::create(vm,
executable, executable->m_unlinkedModuleProgramCodeBlock.get(), scope,
executable->source().provider(), startColumn());
+ ASSERT(throwScope.exception() || codeBlock);
if (!codeBlock) {
exception = throwException(
exec, throwScope,
return nullptr;
}
+ throwScope.release();
return FunctionCodeBlock::create(vm, executable, unlinkedCodeBlock, scope,
source().provider(), source().startOffset(), startColumn());
}