Everywhere: Mark a bunch of function parameters as NOESCAPE

This fixes the relevant warnings when running LibJSGCVerifier. Note that
the analysis is only performed over LibJS-adjacent code, but could be
performed over the entire codebase. That will have to wait for a future
commit.
This commit is contained in:
Matthew Olsson 2024-04-07 16:30:59 -07:00 committed by Andreas Kling
parent 31c5cdcbd5
commit ff00d21d58
16 changed files with 25 additions and 24 deletions

View file

@ -29,7 +29,7 @@ public:
NonnullRefPtr<ProjectFile> create_file(ByteString const& path) const;
void for_each_text_file(Function<void(ProjectFile const&)>) const;
void for_each_text_file(NOESCAPE Function<void(ProjectFile const&)>) const;
ByteString to_absolute_path(ByteString const&) const;
bool project_is_serenity() const;

View file

@ -42,8 +42,8 @@ private:
Vector<ByteString> dependencies {};
};
static HashMap<ByteString, NonnullOwnPtr<LibraryInfo>> get_defined_libraries();
static void for_each_library_definition(Function<void(ByteString, ByteString)>);
static void for_each_library_dependencies(Function<void(ByteString, Vector<StringView>)>);
static void for_each_library_definition(NOESCAPE Function<void(ByteString, ByteString)>);
static void for_each_library_dependencies(NOESCAPE Function<void(ByteString, Vector<StringView>)>);
static ErrorOr<ByteString> component_name(StringView cmake_file_path);
static ErrorOr<void> verify_cmake_is_installed();
static ErrorOr<void> verify_make_is_installed();

View file

@ -20,6 +20,7 @@ ProjectDeclarations& ProjectDeclarations::the()
static ProjectDeclarations s_instance;
return s_instance;
}
void ProjectDeclarations::set_declared_symbols(ByteString const& filename, Vector<CodeComprehension::Declaration> const& declarations)
{
m_document_to_declarations.set(filename, declarations);

View file

@ -114,8 +114,8 @@ public:
protected:
Model();
void for_each_view(Function<void(AbstractView&)>);
void for_each_client(Function<void(ModelClient&)>);
void for_each_view(NOESCAPE Function<void(AbstractView&)>);
void for_each_client(NOESCAPE Function<void(ModelClient&)>);
void did_update(unsigned flags = UpdateFlag::InvalidateAllIndices);
static bool string_matches(StringView str, StringView needle, unsigned flags)

View file

@ -37,11 +37,11 @@ public:
RefPtr<Gfx::Font> get(FlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No);
RefPtr<Gfx::Font> get(FlyString const& family, FlyString const& variant, float point_size, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No);
RefPtr<Gfx::Font> get_by_name(StringView);
void for_each_font(Function<void(Gfx::Font const&)>);
void for_each_fixed_width_font(Function<void(Gfx::Font const&)>);
void for_each_font(NOESCAPE Function<void(Gfx::Font const&)>);
void for_each_fixed_width_font(NOESCAPE Function<void(Gfx::Font const&)>);
void for_each_typeface(Function<void(Typeface const&)>);
void for_each_typeface_with_family_name(FlyString const& family_name, Function<void(Typeface const&)>);
void for_each_typeface(NOESCAPE Function<void(Typeface const&)>);
void for_each_typeface_with_family_name(FlyString const& family_name, NOESCAPE Function<void(Typeface const&)>);
void load_all_fonts_from_uri(StringView);

View file

@ -32,7 +32,7 @@ ThrowCompletionOr<Value> call_impl(VM&, Value function, Value this_value, Readon
ThrowCompletionOr<Value> call_impl(VM&, FunctionObject& function, Value this_value, ReadonlySpan<Value> arguments = {});
ThrowCompletionOr<NonnullGCPtr<Object>> construct_impl(VM&, FunctionObject&, ReadonlySpan<Value> arguments = {}, FunctionObject* new_target = nullptr);
ThrowCompletionOr<size_t> length_of_array_like(VM&, Object const&);
ThrowCompletionOr<MarkedVector<Value>> create_list_from_array_like(VM&, Value, Function<ThrowCompletionOr<void>(Value)> = {});
ThrowCompletionOr<MarkedVector<Value>> create_list_from_array_like(VM&, Value, NOESCAPE Function<ThrowCompletionOr<void>(Value)> = {});
ThrowCompletionOr<FunctionObject*> species_constructor(VM&, Object const&, FunctionObject& default_constructor);
ThrowCompletionOr<Realm*> get_function_realm(VM&, FunctionObject const&);
ThrowCompletionOr<void> initialize_bound_name(VM&, DeprecatedFlyString const&, Value, Environment*);

View file

@ -161,7 +161,7 @@ public:
// 14.7.5 The for-in, for-of, and for-await-of Statements
Optional<Completion> enumerate_object_properties(Function<Optional<Completion>(Value)>) const;
Optional<Completion> enumerate_object_properties(NOESCAPE Function<Optional<Completion>(Value)>) const;
// Implementation-specific storage abstractions

View file

@ -34,7 +34,7 @@ public:
};
static ThrowCompletionOr<NonnullGCPtr<Realm>> create(VM&);
static ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> initialize_host_defined_realm(VM&, Function<Object*(Realm&)> create_global_object, Function<Object*(Realm&)> create_global_this_value);
static ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> initialize_host_defined_realm(VM&, NOESCAPE Function<Object*(Realm&)> create_global_object, NOESCAPE Function<Object*(Realm&)> create_global_this_value);
void set_global_object(Object* global_object, Object* this_value);

View file

@ -42,7 +42,7 @@ public:
struct CustomData {
virtual ~CustomData() = default;
virtual void spin_event_loop_until(JS::SafeFunction<bool()> goal_condition) = 0;
virtual void spin_event_loop_until(NOESCAPE JS::SafeFunction<bool()> goal_condition) = 0;
};
static ErrorOr<NonnullRefPtr<VM>> create(OwnPtr<CustomData> = {});

View file

@ -26,7 +26,7 @@ public:
static RandomnessSource live() { return RandomnessSource(RandomRun(), true); }
static RandomnessSource recorded(RandomRun const& run) { return RandomnessSource(run, false); }
RandomRun& run() { return m_run; }
u64 draw_value(u64 max, Function<u64()> random_generator)
u64 draw_value(u64 max, NOESCAPE Function<u64()> random_generator)
{
// Live: use the random generator and remember the value.
if (m_is_live) {

View file

@ -84,7 +84,7 @@ ErrorOr<void> initialize_main_thread_vm();
JS::VM& main_thread_vm();
void queue_mutation_observer_microtask(DOM::Document const&);
NonnullOwnPtr<JS::ExecutionContext> create_a_new_javascript_realm(JS::VM&, Function<JS::Object*(JS::Realm&)> create_global_object, Function<JS::Object*(JS::Realm&)> create_global_this_value);
NonnullOwnPtr<JS::ExecutionContext> create_a_new_javascript_realm(JS::VM&, NOESCAPE Function<JS::Object*(JS::Realm&)> create_global_object, NOESCAPE Function<JS::Object*(JS::Realm&)> create_global_this_value);
void invoke_custom_element_reactions(Vector<JS::Handle<DOM::Element>>& element_queue);
}

View file

@ -134,9 +134,9 @@ public:
int client_width() const;
int client_height() const;
void for_each_attribute(Function<void(Attr const&)>) const;
void for_each_attribute(NOESCAPE Function<void(Attr const&)>) const;
void for_each_attribute(Function<void(FlyString const&, String const&)>) const;
void for_each_attribute(NOESCAPE Function<void(FlyString const&, String const&)>) const;
bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
Vector<FlyString> const& class_names() const { return m_classes; }

View file

@ -38,8 +38,8 @@ public:
TaskQueue& microtask_queue() { return *m_microtask_queue; }
TaskQueue const& microtask_queue() const { return *m_microtask_queue; }
void spin_until(JS::SafeFunction<bool()> goal_condition);
void spin_processing_tasks_with_source_until(Task::Source, JS::SafeFunction<bool()> goal_condition);
void spin_until(NOESCAPE JS::SafeFunction<bool()> goal_condition);
void spin_processing_tasks_with_source_until(Task::Source, NOESCAPE JS::SafeFunction<bool()> goal_condition);
void process();
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#termination-nesting-level

View file

@ -34,8 +34,8 @@ public:
return m_tasks.take_first();
}
void remove_tasks_matching(Function<bool(HTML::Task const&)>);
JS::MarkedVector<JS::NonnullGCPtr<Task>> take_tasks_matching(Function<bool(HTML::Task const&)>);
void remove_tasks_matching(NOESCAPE Function<bool(HTML::Task const&)>);
JS::MarkedVector<JS::NonnullGCPtr<Task>> take_tasks_matching(NOESCAPE Function<bool(HTML::Task const&)>);
Task const* last_added_task() const;

View file

@ -221,7 +221,7 @@ public:
m_data.get<OwnPtr<Vector<Attribute>>>().clear();
}
void for_each_attribute(Function<IterationDecision(Attribute const&)> callback) const
void for_each_attribute(NOESCAPE Function<IterationDecision(Attribute const&)> callback) const
{
VERIFY(is_start_tag() || is_end_tag());
auto* ptr = tag_attributes();
@ -233,7 +233,7 @@ public:
}
}
void for_each_attribute(Function<IterationDecision(Attribute&)> callback)
void for_each_attribute(NOESCAPE Function<IterationDecision(Attribute&)> callback)
{
VERIFY(is_start_tag() || is_end_tag());
auto* ptr = tag_attributes();

View file

@ -19,7 +19,7 @@ public:
virtual ~EventLoopPlugin();
virtual void spin_until(JS::SafeFunction<bool()> goal_condition) = 0;
virtual void spin_until(NOESCAPE JS::SafeFunction<bool()> goal_condition) = 0;
virtual void deferred_invoke(JS::SafeFunction<void()>) = 0;
virtual NonnullRefPtr<Timer> create_timer() = 0;
virtual void quit() = 0;