зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1834478 - Add public API to test and clear errors on JS::FrontendContext. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D179428
This commit is contained in:
Родитель
18e588031f
Коммит
5cc53bab49
|
@ -36,6 +36,13 @@ JS_PUBLIC_API void DestroyFrontendContext(JS::FrontendContext* fc);
|
|||
JS_PUBLIC_API void SetNativeStackQuota(JS::FrontendContext* fc,
|
||||
JS::NativeStackSize stackSize);
|
||||
|
||||
// Returns true if there was any error reported to given FrontendContext.
|
||||
JS_PUBLIC_API bool HadFrontendErrors(JS::FrontendContext* fc);
|
||||
|
||||
// Clear errors reported to given FrontendContext.
|
||||
// No-op when there's no errors.
|
||||
JS_PUBLIC_API void ClearFrontendErrors(JS::FrontendContext* fc);
|
||||
|
||||
/*
|
||||
* Set supported import assertions on a FrontendContext to be used with
|
||||
* CompileModuleScriptToStencil. May only be set once for each FrontendContext.
|
||||
|
|
|
@ -32,6 +32,14 @@ JS_PUBLIC_API void JS::SetNativeStackQuota(JS::FrontendContext* fc,
|
|||
fc->setStackQuota(stackSize);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::HadFrontendErrors(JS::FrontendContext* fc) {
|
||||
return fc->hadErrors();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API void JS::ClearFrontendErrors(JS::FrontendContext* fc) {
|
||||
fc->clearErrors();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::SetSupportedImportAssertions(
|
||||
FrontendContext* fc,
|
||||
const JS::ImportAssertionVector& supportedImportAssertions) {
|
||||
|
|
|
@ -16,6 +16,14 @@
|
|||
|
||||
using namespace js;
|
||||
|
||||
void FrontendErrors::clearErrors() {
|
||||
error.reset();
|
||||
warnings.clear();
|
||||
overRecursed = false;
|
||||
outOfMemory = false;
|
||||
allocationOverflow = false;
|
||||
}
|
||||
|
||||
void FrontendAllocator::reportAllocationOverflow() {
|
||||
fc_->onAllocationOverflow();
|
||||
}
|
||||
|
@ -76,6 +84,11 @@ bool FrontendContext::hadErrors() const {
|
|||
return errors_.hadErrors();
|
||||
}
|
||||
|
||||
void FrontendContext::clearErrors() {
|
||||
MOZ_ASSERT(!maybeCx_);
|
||||
return errors_.clearErrors();
|
||||
}
|
||||
|
||||
void* FrontendContext::onOutOfMemory(AllocFunction allocFunc, arena_id_t arena,
|
||||
size_t nbytes, void* reallocPtr) {
|
||||
addPendingOutOfMemory();
|
||||
|
|
|
@ -45,6 +45,8 @@ struct FrontendErrors {
|
|||
bool hadErrors() const {
|
||||
return outOfMemory || overRecursed || allocationOverflow || error;
|
||||
}
|
||||
|
||||
void clearErrors();
|
||||
};
|
||||
|
||||
class FrontendAllocator : public MallocProvider<FrontendAllocator> {
|
||||
|
@ -167,6 +169,7 @@ class FrontendContext {
|
|||
bool hadOverRecursed() const { return errors_.overRecursed; }
|
||||
bool hadAllocationOverflow() const { return errors_.allocationOverflow; }
|
||||
bool hadErrors() const;
|
||||
void clearErrors();
|
||||
|
||||
#ifdef __wasi__
|
||||
void incWasiRecursionDepth();
|
||||
|
|
Загрузка…
Ссылка в новой задаче