LibJS+Everywhere: Remove all VM::clear_exception() calls
Since VM::exception() no longer exists this is now useless. All of these calls to clear_exception were just to clear the VM state after some (potentially) failed evaluation and did not use the exception itself.
This commit is contained in:
parent
9264f9d24e
commit
1c4c251be3
Notes:
sideshowbarker
2024-07-17 19:37:54 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/1c4c251be34 Pull-request: https://github.com/SerenityOS/serenity/pull/12343 Reviewed-by: https://github.com/linusg
14 changed files with 2 additions and 27 deletions
|
@ -214,7 +214,6 @@ int main(int, char**)
|
|||
auto completion = interpreter->run(parse_result.value());
|
||||
if (completion.is_error()) {
|
||||
result = 1;
|
||||
vm->clear_exception();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,6 @@ void EvaluateExpressionDialog::handle_evaluation(const String& expression)
|
|||
}
|
||||
|
||||
if (result.is_error()) {
|
||||
m_interpreter->vm().clear_exception();
|
||||
output_html.append("Uncaught exception: ");
|
||||
auto error = *result.throw_completion().value();
|
||||
if (error.is_object())
|
||||
|
|
|
@ -55,7 +55,6 @@ ThrowCompletionOr<Object*> ArrayBufferConstructor::construct(FunctionObject& new
|
|||
auto error = byte_length_or_error.release_error();
|
||||
if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) {
|
||||
// Re-throw more specific RangeError
|
||||
vm.clear_exception();
|
||||
return vm.throw_completion<RangeError>(global_object(), ErrorType::InvalidLength, "array buffer");
|
||||
}
|
||||
return error;
|
||||
|
|
|
@ -38,7 +38,6 @@ ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::react_to_async_task_complet
|
|||
|
||||
if (generator_result.is_throw_completion()) {
|
||||
VERIFY(generator_result.throw_completion().type() == Completion::Type::Throw);
|
||||
vm.clear_exception();
|
||||
auto promise = Promise::create(global_object);
|
||||
promise->reject(*generator_result.throw_completion().value());
|
||||
return promise;
|
||||
|
|
|
@ -106,7 +106,6 @@ ThrowCompletionOr<void> ObjectEnvironment::set_mutable_binding(GlobalObject& glo
|
|||
return result_or_error.release_error();
|
||||
auto property = property_or_error.release_value();
|
||||
if (property.has_value() && !property->writable.value_or(true)) {
|
||||
vm.clear_exception();
|
||||
return vm.throw_completion<TypeError>(global_object, ErrorType::DescWriteNonWritable, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,6 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
|
|||
if (then.is_throw_completion()) {
|
||||
// a. Return RejectPromise(promise, then.[[Value]]).
|
||||
dbgln_if(PROMISE_DEBUG, "[Promise @ {} / PromiseResolvingFunction]: Exception while getting 'then' property, rejecting with error", &promise);
|
||||
vm.clear_exception();
|
||||
return promise.reject(*then.throw_completion().value());
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ PromiseReactionJob::PromiseReactionJob(PromiseReaction& reaction, Value argument
|
|||
// 27.2.2.1 NewPromiseReactionJob ( reaction, argument ), https://tc39.es/ecma262/#sec-newpromisereactionjob
|
||||
ThrowCompletionOr<Value> PromiseReactionJob::call()
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
// a. Let promiseCapability be reaction.[[Capability]].
|
||||
|
@ -83,8 +82,6 @@ ThrowCompletionOr<Value> PromiseReactionJob::call()
|
|||
|
||||
// h. If handlerResult is an abrupt completion, then
|
||||
if (handler_result.is_abrupt()) {
|
||||
vm.clear_exception();
|
||||
|
||||
// i. Let status be Call(promiseCapability.[[Reject]], undefined, « handlerResult.[[Value]] »).
|
||||
auto* reject_function = promise_capability.value().reject;
|
||||
dbgln_if(PROMISE_DEBUG, "[PromiseReactionJob @ {}]: Calling PromiseCapability's reject function @ {}", this, reject_function);
|
||||
|
@ -125,7 +122,6 @@ PromiseResolveThenableJob::PromiseResolveThenableJob(Promise& promise_to_resolve
|
|||
// 27.2.2.2 NewPromiseResolveThenableJob ( promiseToResolve, thenable, then ), https://tc39.es/ecma262/#sec-newpromiseresolvethenablejob
|
||||
ThrowCompletionOr<Value> PromiseResolveThenableJob::call()
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
// a. Let resolvingFunctions be CreateResolvingFunctions(promiseToResolve).
|
||||
|
@ -137,8 +133,6 @@ ThrowCompletionOr<Value> PromiseResolveThenableJob::call()
|
|||
|
||||
// c. If thenCallResult is an abrupt completion, then
|
||||
if (then_call_result.is_error()) {
|
||||
vm.clear_exception();
|
||||
|
||||
// i. Let status be Call(resolvingFunctions.[[Reject]], undefined, « thenCallResult.[[Value]] »).
|
||||
dbgln_if(PROMISE_DEBUG, "[PromiseResolveThenableJob @ {}]: then_call_result is an abrupt completion, calling reject function with value {}", this, *then_call_result.throw_completion().value());
|
||||
auto status = JS::call(global_object, &reject_function, js_undefined(), *then_call_result.throw_completion().value());
|
||||
|
|
|
@ -25,8 +25,6 @@ struct PromiseCapability {
|
|||
auto _temporary_try_or_reject_result = (expression); \
|
||||
/* 1. If value is an abrupt completion, then */ \
|
||||
if (_temporary_try_or_reject_result.is_error()) { \
|
||||
global_object.vm().clear_exception(); \
|
||||
\
|
||||
/* a. Perform ? Call(capability.[[Reject]], undefined, « value.[[Value]] »). */ \
|
||||
TRY(JS::call(global_object, *capability.reject, js_undefined(), *_temporary_try_or_reject_result.release_error().value())); \
|
||||
\
|
||||
|
@ -44,8 +42,6 @@ struct PromiseCapability {
|
|||
auto _temporary_try_or_reject_result = (expression); \
|
||||
/* 1. If value is an abrupt completion, then */ \
|
||||
if (_temporary_try_or_reject_result.is_error()) { \
|
||||
global_object.vm().clear_exception(); \
|
||||
\
|
||||
/* a. Perform ? Call(capability.[[Reject]], undefined, « value.[[Value]] »). */ \
|
||||
TRY(JS::call(global_object, *capability.reject, js_undefined(), *_temporary_try_or_reject_result.release_error().value())); \
|
||||
\
|
||||
|
|
|
@ -77,8 +77,6 @@ ThrowCompletionOr<TimeZone*> create_temporal_time_zone(GlobalObject& global_obje
|
|||
|
||||
// 4. If offsetNanosecondsResult is an abrupt completion, then
|
||||
if (offset_nanoseconds_result.is_throw_completion()) {
|
||||
global_object.vm().clear_exception();
|
||||
|
||||
// a. Assert: ! CanonicalizeTimeZoneName(identifier) is identifier.
|
||||
VERIFY(canonicalize_time_zone_name(identifier) == identifier);
|
||||
|
||||
|
|
|
@ -476,7 +476,6 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
|||
auto error = array_length_or_error.release_error(); \
|
||||
if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) { \
|
||||
/* Re-throw more specific RangeError */ \
|
||||
vm.clear_exception(); \
|
||||
return vm.throw_completion<RangeError>(global_object(), ErrorType::InvalidLength, "typed array"); \
|
||||
} \
|
||||
return error; \
|
||||
|
|
|
@ -48,7 +48,6 @@ public:
|
|||
void push_interpreter(Interpreter&);
|
||||
void pop_interpreter(Interpreter&);
|
||||
|
||||
void clear_exception() { }
|
||||
void dump_backtrace() const;
|
||||
|
||||
class InterpreterExecutionScope {
|
||||
|
|
|
@ -159,10 +159,9 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::compile)
|
|||
// FIXME: This shouldn't block!
|
||||
auto buffer_or_error = vm.argument(0).to_object(global_object);
|
||||
JS::Value rejection_value;
|
||||
if (buffer_or_error.is_error()) {
|
||||
if (buffer_or_error.is_error())
|
||||
rejection_value = *buffer_or_error.throw_completion().value();
|
||||
vm.clear_exception();
|
||||
}
|
||||
|
||||
auto promise = JS::Promise::create(global_object);
|
||||
if (!rejection_value.is_empty()) {
|
||||
promise->reject(rejection_value);
|
||||
|
@ -217,7 +216,6 @@ JS::ThrowCompletionOr<size_t> WebAssemblyObject::instantiate_module(Wasm::Module
|
|||
|
||||
auto result_or_error = JS::call(global_object, function, JS::js_undefined(), move(argument_values));
|
||||
if (result_or_error.is_error()) {
|
||||
vm.clear_exception();
|
||||
return Wasm::Trap();
|
||||
}
|
||||
if (type.results().is_empty())
|
||||
|
@ -325,7 +323,6 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::instantiate)
|
|||
bool should_return_module = false;
|
||||
if (buffer_or_error.is_error()) {
|
||||
auto rejection_value = *buffer_or_error.throw_completion().value();
|
||||
vm.clear_exception();
|
||||
promise->reject(rejection_value);
|
||||
return promise;
|
||||
}
|
||||
|
|
|
@ -346,7 +346,6 @@ void ClientConnection::run_javascript(String const& js_source)
|
|||
|
||||
if (result.is_error()) {
|
||||
dbgln("Exception :(");
|
||||
interpreter.vm().clear_exception();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ void WebContentConsoleClient::handle_input(String const& js_source)
|
|||
}
|
||||
|
||||
if (result.is_error()) {
|
||||
m_interpreter->vm().clear_exception();
|
||||
output_html.append("Uncaught exception: ");
|
||||
auto error = *result.throw_completion().value();
|
||||
if (error.is_object())
|
||||
|
|
Loading…
Add table
Reference in a new issue