LibJS: Repurpose MUST_OR_THROW_OOM to propagate general internal errors

There are now no users of the MUST_OR_THROW_OOM macro. Let's rename this
macro to indicate it may be used to propagate any internal error (such
as the call stack limit error) in places that would otherwise crash due
to a MUST/VERIFY invocation.

Note there's no actual functional change here, as we weren't able to
ensure the internal error was an OOM error previously.
This commit is contained in:
Timothy Flynn 2025-02-03 21:38:15 -05:00 committed by Tim Flynn
commit b91a0f5403
Notes: github-actions[bot] 2025-02-05 13:06:06 +00:00

View file

@ -31,24 +31,23 @@ namespace JS {
_temporary_result.release_value(); \
})
#define MUST_OR_THROW_OOM(...) \
({ \
/* Ignore -Wshadow to allow nesting the macro. */ \
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
auto&& _temporary_result = (__VA_ARGS__)); \
if (_temporary_result.is_error()) { \
auto _completion = _temporary_result.release_error(); \
\
/* We can't explicitly check for OOM because InternalError does not store the ErrorType */ \
VERIFY(_completion.value().has_value()); \
VERIFY(_completion.value()->is_object()); \
VERIFY(::AK::is<JS::InternalError>(_completion.value()->as_object())); \
\
return _completion; \
} \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_temporary_result.release_value(); \
#define MUST_OR_THROW_INTERNAL_ERROR(...) \
({ \
/* Ignore -Wshadow to allow nesting the macro. */ \
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
auto&& _temporary_result = (__VA_ARGS__)); \
if (_temporary_result.is_error()) { \
auto _completion = _temporary_result.release_error(); \
\
VERIFY(_completion.value().has_value()); \
VERIFY(_completion.value()->is_object()); \
VERIFY(::AK::is<JS::InternalError>(_completion.value()->as_object())); \
\
return _completion; \
} \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_temporary_result.release_value(); \
})
// 6.2.3 The Completion Record Specification Type, https://tc39.es/ecma262/#sec-completion-record-specification-type