зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1773324 - Pass ErrorContext down through Smoosh functions r=arai
Differential Revision: https://phabricator.services.mozilla.com/D152458
This commit is contained in:
Родитель
6cf08032de
Коммит
e1615d73bb
|
@ -175,7 +175,7 @@ class MOZ_STACK_CLASS ScriptCompiler : public SourceAwareCompiler<Unit> {
|
|||
|
||||
#ifdef JS_ENABLE_SMOOSH
|
||||
[[nodiscard]] static bool TrySmoosh(
|
||||
JSContext* cx, CompilationInput& input,
|
||||
JSContext* cx, ErrorContext* ec, CompilationInput& input,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf,
|
||||
UniquePtr<ExtensibleCompilationStencil>& stencilOut) {
|
||||
MOZ_ASSERT(!stencilOut);
|
||||
|
@ -185,7 +185,7 @@ class MOZ_STACK_CLASS ScriptCompiler : public SourceAwareCompiler<Unit> {
|
|||
}
|
||||
|
||||
JSRuntime* rt = cx->runtime();
|
||||
if (!Smoosh::tryCompileGlobalScriptToExtensibleStencil(cx, input, srcBuf,
|
||||
if (!Smoosh::tryCompileGlobalScriptToExtensibleStencil(cx, ec, input, srcBuf,
|
||||
stencilOut)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -207,7 +207,8 @@ class MOZ_STACK_CLASS ScriptCompiler : public SourceAwareCompiler<Unit> {
|
|||
}
|
||||
|
||||
[[nodiscard]] static bool TrySmoosh(
|
||||
JSContext* cx, CompilationInput& input, JS::SourceText<char16_t>& srcBuf,
|
||||
JSContext* cx, ErrorContext* ec, CompilationInput& input,
|
||||
JS::SourceText<char16_t>& srcBuf,
|
||||
UniquePtr<ExtensibleCompilationStencil>& stencilOut) {
|
||||
MOZ_ASSERT(!stencilOut);
|
||||
return true;
|
||||
|
@ -230,7 +231,7 @@ template <typename Unit>
|
|||
#ifdef JS_ENABLE_SMOOSH
|
||||
{
|
||||
UniquePtr<ExtensibleCompilationStencil> extensibleStencil;
|
||||
if (!TrySmoosh(cx, input, srcBuf, extensibleStencil)) {
|
||||
if (!TrySmoosh(cx, ec, input, srcBuf, extensibleStencil)) {
|
||||
return false;
|
||||
}
|
||||
if (extensibleStencil) {
|
||||
|
|
|
@ -260,7 +260,8 @@ bool ConvertScopeStencil(JSContext* cx, const SmooshResult& result,
|
|||
|
||||
// Given the result of SmooshMonkey's parser, convert a list of RegExp data
|
||||
// into a list of RegExpStencil.
|
||||
bool ConvertRegExpData(JSContext* cx, const SmooshResult& result,
|
||||
bool ConvertRegExpData(JSContext* cx, ErrorContext* ec,
|
||||
const SmooshResult& result,
|
||||
CompilationState& compilationState) {
|
||||
auto len = result.regexps.len;
|
||||
if (len == 0) {
|
||||
|
@ -277,7 +278,6 @@ bool ConvertRegExpData(JSContext* cx, const SmooshResult& result,
|
|||
return false;
|
||||
}
|
||||
|
||||
MainThreadErrorContext ec(cx);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
SmooshRegExpItem& item = result.regexps.data[i];
|
||||
auto s = smoosh_get_slice_at(result, item.pattern);
|
||||
|
@ -315,7 +315,7 @@ bool ConvertRegExpData(JSContext* cx, const SmooshResult& result,
|
|||
|
||||
mozilla::Range<const char16_t> range(pattern.get(), length);
|
||||
|
||||
TokenStreamAnyChars ts(cx, &ec, compilationState.input.options,
|
||||
TokenStreamAnyChars ts(cx, ec, compilationState.input.options,
|
||||
/* smg = */ nullptr);
|
||||
|
||||
// See Parser<FullParseHandler, Unit>::newRegExp.
|
||||
|
@ -543,19 +543,18 @@ class AutoFreeSmooshParseResult {
|
|||
|
||||
void InitSmoosh() { smoosh_init(); }
|
||||
|
||||
void ReportSmooshCompileError(JSContext* cx, ErrorMetadata&& metadata,
|
||||
int errorNumber, ...) {
|
||||
MainThreadErrorContext ec(cx);
|
||||
void ReportSmooshCompileError(JSContext* cx, ErrorContext* ec,
|
||||
ErrorMetadata&& metadata, int errorNumber, ...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
ReportCompileErrorUTF8(&ec, std::move(metadata), /* notes = */ nullptr,
|
||||
ReportCompileErrorUTF8(ec, std::move(metadata), /* notes = */ nullptr,
|
||||
errorNumber, &args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool Smoosh::tryCompileGlobalScriptToExtensibleStencil(
|
||||
JSContext* cx, CompilationInput& input,
|
||||
JSContext* cx, ErrorContext* ec, CompilationInput& input,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf,
|
||||
UniquePtr<ExtensibleCompilationStencil>& stencilOut) {
|
||||
// FIXME: check info members and return with *unimplemented = true
|
||||
|
@ -576,7 +575,7 @@ bool Smoosh::tryCompileGlobalScriptToExtensibleStencil(
|
|||
metadata.lineNumber = 1;
|
||||
metadata.columnNumber = 0;
|
||||
metadata.isMuted = false;
|
||||
ReportSmooshCompileError(cx, std::move(metadata),
|
||||
ReportSmooshCompileError(cx, ec, std::move(metadata),
|
||||
JSMSG_SMOOSH_COMPILE_ERROR,
|
||||
reinterpret_cast<const char*>(result.error.data));
|
||||
return false;
|
||||
|
@ -603,7 +602,7 @@ bool Smoosh::tryCompileGlobalScriptToExtensibleStencil(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!ConvertRegExpData(cx, result, compilationState)) {
|
||||
if (!ConvertRegExpData(cx, ec, result, compilationState)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ struct SmooshResult;
|
|||
namespace js {
|
||||
|
||||
class ScriptSourceObject;
|
||||
class ErrorContext;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
|
@ -38,7 +39,7 @@ struct CompilationState;
|
|||
class Smoosh {
|
||||
public:
|
||||
[[nodiscard]] static bool tryCompileGlobalScriptToExtensibleStencil(
|
||||
JSContext* cx, CompilationInput& input,
|
||||
JSContext* cx, ErrorContext* ec, CompilationInput& input,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf,
|
||||
UniquePtr<ExtensibleCompilationStencil>& stencilOut);
|
||||
};
|
||||
|
|
|
@ -5981,11 +5981,12 @@ static bool FrontendTest(JSContext* cx, unsigned argc, Value* vp,
|
|||
return false;
|
||||
}
|
||||
|
||||
MainThreadErrorContext ec(cx);
|
||||
Rooted<frontend::CompilationInput> input(
|
||||
cx, frontend::CompilationInput(options));
|
||||
UniquePtr<frontend::ExtensibleCompilationStencil> stencil;
|
||||
if (!Smoosh::tryCompileGlobalScriptToExtensibleStencil(
|
||||
cx, input.get(), srcBuf, stencil)) {
|
||||
cx, &ec, input.get(), srcBuf, stencil)) {
|
||||
return false;
|
||||
}
|
||||
if (!stencil) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче