summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-02-07 15:14:31 +0100
committerLinus Groh <mail@linusgroh.de>2022-02-08 09:12:42 +0000
commit1c4c251be34d4c94bc07adcd70a336558ed627d9 (patch)
treebd7692ce38d2bc57bced835fe9e1e33f82338089
parent9264f9d24e10c3ca8d522450bc9152e69cbd6cda (diff)
downloadserenity-1c4c251be34d4c94bc07adcd70a336558ed627d9.zip
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.
-rw-r--r--Meta/Lagom/Fuzzers/FuzzilliJs.cpp1
-rw-r--r--Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp1
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp1
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp1
-rw-r--r--Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp1
-rw-r--r--Userland/Libraries/LibJS/Runtime/Promise.cpp1
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseReaction.h4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.cpp1
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.h1
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp7
-rw-r--r--Userland/Services/WebContent/ClientConnection.cpp1
-rw-r--r--Userland/Services/WebContent/WebContentConsoleClient.cpp1
14 files changed, 2 insertions, 27 deletions
diff --git a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
index e5190b310c..d96353bb6b 100644
--- a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
@@ -214,7 +214,6 @@ int main(int, char**)
auto completion = interpreter->run(parse_result.value());
if (completion.is_error()) {
result = 1;
- vm->clear_exception();
}
}
diff --git a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp
index 42cd2a3192..bc06aa8996 100644
--- a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp
+++ b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp
@@ -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())
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
index f6781a9750..43318a0328 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
@@ -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;
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp
index b91a173e47..e59b98ad8c 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp
@@ -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;
diff --git a/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp
index b5d10d312e..4df0e07b9d 100644
--- a/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp
@@ -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);
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/Promise.cpp b/Userland/Libraries/LibJS/Runtime/Promise.cpp
index c2a05e75ff..d5181f74fd 100644
--- a/Userland/Libraries/LibJS/Runtime/Promise.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Promise.cpp
@@ -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());
}
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp b/Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp
index d1fbbae63f..087b98a96f 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp
@@ -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());
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h
index bb31e6fc96..9300096a75 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h
+++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h
@@ -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())); \
\
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
index c627e05c7e..37a68e0224 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
@@ -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);
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
index 0c760f1b97..1405e3ef7c 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
@@ -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; \
diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h
index 2f970785a3..126c20c30e 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.h
+++ b/Userland/Libraries/LibJS/Runtime/VM.h
@@ -48,7 +48,6 @@ public:
void push_interpreter(Interpreter&);
void pop_interpreter(Interpreter&);
- void clear_exception() { }
void dump_backtrace() const;
class InterpreterExecutionScope {
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp
index 929ca881e6..b875626d43 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp
@@ -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;
}
diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp
index e6fbef7a06..843d14ff7a 100644
--- a/Userland/Services/WebContent/ClientConnection.cpp
+++ b/Userland/Services/WebContent/ClientConnection.cpp
@@ -346,7 +346,6 @@ void ClientConnection::run_javascript(String const& js_source)
if (result.is_error()) {
dbgln("Exception :(");
- interpreter.vm().clear_exception();
}
}
diff --git a/Userland/Services/WebContent/WebContentConsoleClient.cpp b/Userland/Services/WebContent/WebContentConsoleClient.cpp
index a4a7e9de87..6bbbfe3478 100644
--- a/Userland/Services/WebContent/WebContentConsoleClient.cpp
+++ b/Userland/Services/WebContent/WebContentConsoleClient.cpp
@@ -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())