diff --git a/include/natalie/abstract_method_object.hpp b/include/natalie/abstract_method_object.hpp index 275c62614..92eaee910 100644 --- a/include/natalie/abstract_method_object.hpp +++ b/include/natalie/abstract_method_object.hpp @@ -21,7 +21,7 @@ class AbstractMethodObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_method); + visitor.visit(m_method); } virtual void gc_inspect(char *buf, size_t len) const override { diff --git a/include/natalie/array_object.hpp b/include/natalie/array_object.hpp index 9c474b128..52d15febe 100644 --- a/include/natalie/array_object.hpp +++ b/include/natalie/array_object.hpp @@ -210,7 +210,7 @@ class ArrayObject : public Object { virtual void visit_children(Visitor &visitor) const override final { Object::visit_children(visitor); for (auto val : m_vector) { - visitor.enqueue(val); + visitor.visit(val); } } diff --git a/include/natalie/array_packer/float_handler.hpp b/include/natalie/array_packer/float_handler.hpp index c13ddaac3..c95ddfb06 100644 --- a/include/natalie/array_packer/float_handler.hpp +++ b/include/natalie/array_packer/float_handler.hpp @@ -17,7 +17,7 @@ namespace ArrayPacker { String pack(Env *env); virtual void visit_children(Visitor &visitor) const override { - visitor.enqueue(m_source); + visitor.visit(m_source); } private: diff --git a/include/natalie/array_packer/integer_handler.hpp b/include/natalie/array_packer/integer_handler.hpp index 0b7bd599b..1e0268e2e 100644 --- a/include/natalie/array_packer/integer_handler.hpp +++ b/include/natalie/array_packer/integer_handler.hpp @@ -17,7 +17,7 @@ namespace ArrayPacker { String pack(Env *env); virtual void visit_children(Visitor &visitor) const override { - visitor.enqueue(m_source); + visitor.visit(m_source); } private: diff --git a/include/natalie/array_packer/packer.hpp b/include/natalie/array_packer/packer.hpp index 3f0d2f0d3..34119922d 100644 --- a/include/natalie/array_packer/packer.hpp +++ b/include/natalie/array_packer/packer.hpp @@ -25,8 +25,8 @@ namespace ArrayPacker { StringObject *pack(Env *env, StringObject *buffer); virtual void visit_children(Visitor &visitor) const override { - visitor.enqueue(m_source); - visitor.enqueue(m_encoding); + visitor.visit(m_source); + visitor.visit(m_encoding); } private: diff --git a/include/natalie/array_packer/string_handler.hpp b/include/natalie/array_packer/string_handler.hpp index 1f1f0ae0b..7a5c758c7 100644 --- a/include/natalie/array_packer/string_handler.hpp +++ b/include/natalie/array_packer/string_handler.hpp @@ -20,7 +20,7 @@ namespace ArrayPacker { using PackHandlerFn = void (StringHandler::*)(); virtual void visit_children(Visitor &visitor) const override { - visitor.enqueue(m_string_object); + visitor.visit(m_string_object); } private: diff --git a/include/natalie/binding_object.hpp b/include/natalie/binding_object.hpp index 7de342a93..c05e55db6 100644 --- a/include/natalie/binding_object.hpp +++ b/include/natalie/binding_object.hpp @@ -15,7 +15,7 @@ class BindingObject : public Object { virtual void visit_children(Visitor &visitor) const override final { Object::visit_children(visitor); - visitor.enqueue(&m_env); + visitor.visit(&m_env); } Value source_location() const; diff --git a/include/natalie/block.hpp b/include/natalie/block.hpp index 06be61350..3d3cef734 100644 --- a/include/natalie/block.hpp +++ b/include/natalie/block.hpp @@ -56,9 +56,9 @@ class Block : public Cell { void copy_fn_pointer_to_method(Method *); virtual void visit_children(Visitor &visitor) const override final { - visitor.enqueue(m_env); - visitor.enqueue(m_calling_env); - visitor.enqueue(m_self); + visitor.visit(m_env); + visitor.visit(m_calling_env); + visitor.visit(m_self); } virtual void gc_inspect(char *buf, size_t len) const override { diff --git a/include/natalie/complex_object.hpp b/include/natalie/complex_object.hpp index 1efbd80ee..565c4279d 100644 --- a/include/natalie/complex_object.hpp +++ b/include/natalie/complex_object.hpp @@ -42,8 +42,8 @@ class ComplexObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_real); - visitor.enqueue(m_imaginary); + visitor.visit(m_real); + visitor.visit(m_imaginary); } private: diff --git a/include/natalie/dir_object.hpp b/include/natalie/dir_object.hpp index a38700f74..4b7c14a17 100644 --- a/include/natalie/dir_object.hpp +++ b/include/natalie/dir_object.hpp @@ -30,8 +30,8 @@ class DirObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_path); - visitor.enqueue(m_encoding); + visitor.visit(m_path); + visitor.visit(m_encoding); } static Value size_fn(Env *env, Value self, Args, Block *) { diff --git a/include/natalie/enumerator/arithmetic_sequence_object.hpp b/include/natalie/enumerator/arithmetic_sequence_object.hpp index 75049725b..6e077aab5 100644 --- a/include/natalie/enumerator/arithmetic_sequence_object.hpp +++ b/include/natalie/enumerator/arithmetic_sequence_object.hpp @@ -45,9 +45,9 @@ class Enumerator::ArithmeticSequenceObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_begin); - visitor.enqueue(m_end); - visitor.enqueue(m_step); + visitor.visit(m_begin); + visitor.visit(m_end); + visitor.visit(m_step); } private: diff --git a/include/natalie/gc/cell.hpp b/include/natalie/gc/cell.hpp index fd38167ca..e0d899876 100644 --- a/include/natalie/gc/cell.hpp +++ b/include/natalie/gc/cell.hpp @@ -22,8 +22,8 @@ class Cell { class Visitor { public: - virtual void enqueue(const Cell *cell) = 0; - void enqueue(Value); + virtual void visit(const Cell *cell) = 0; + void visit(Value); }; virtual void visit_children(Visitor &) const { diff --git a/include/natalie/gc/marking_visitor.hpp b/include/natalie/gc/marking_visitor.hpp index db320b8b1..b249ee1ec 100644 --- a/include/natalie/gc/marking_visitor.hpp +++ b/include/natalie/gc/marking_visitor.hpp @@ -4,16 +4,11 @@ #include "tm/vector.hpp" #include -// time boardslam.rb 3 5 1 -// 1.656 using C stack -// 1.692 using std::stack -// 2.847 using std::queue - namespace Natalie { class MarkingVisitor : public Cell::Visitor { public: - virtual void enqueue(const Cell *cell) override final { + virtual void visit(const Cell *cell) override final { if (!cell || cell->is_marked()) return; m_stack.push(cell); } diff --git a/include/natalie/hash_object.hpp b/include/natalie/hash_object.hpp index 82f6d035d..d6f90c9b6 100644 --- a/include/natalie/hash_object.hpp +++ b/include/natalie/hash_object.hpp @@ -25,10 +25,10 @@ class HashObject : public Object { bool removed { false }; virtual void visit_children(Visitor &visitor) const override final { - visitor.enqueue(prev); - visitor.enqueue(next); - visitor.enqueue(key); - visitor.enqueue(val); + visitor.visit(prev); + visitor.visit(next); + visitor.visit(key); + visitor.visit(val); } }; diff --git a/include/natalie/io_object.hpp b/include/natalie/io_object.hpp index f34865d75..5e6012a3b 100644 --- a/include/natalie/io_object.hpp +++ b/include/natalie/io_object.hpp @@ -41,9 +41,9 @@ class IoObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_external_encoding); - visitor.enqueue(m_internal_encoding); - visitor.enqueue(m_path); + visitor.visit(m_external_encoding); + visitor.visit(m_internal_encoding); + visitor.visit(m_path); } static Value size_fn(Env *env, Value self, Args, Block *) { diff --git a/include/natalie/managed_vector.hpp b/include/natalie/managed_vector.hpp index 56cf37f70..51680cd41 100644 --- a/include/natalie/managed_vector.hpp +++ b/include/natalie/managed_vector.hpp @@ -20,7 +20,7 @@ class ManagedVector : public Cell, public TM::Vector { virtual void visit_children(Visitor &visitor) const override final { for (auto it = TM::Vector::begin(); it != TM::Vector::end(); ++it) { - visitor.enqueue(*it); + visitor.visit(*it); } } diff --git a/include/natalie/match_data_object.hpp b/include/natalie/match_data_object.hpp index 563426531..365b857ab 100644 --- a/include/natalie/match_data_object.hpp +++ b/include/natalie/match_data_object.hpp @@ -71,8 +71,8 @@ class MatchDataObject : public Object { virtual void visit_children(Visitor &visitor) const override final { Object::visit_children(visitor); - visitor.enqueue(m_string); - visitor.enqueue(m_regexp); + visitor.visit(m_string); + visitor.visit(m_regexp); } virtual String dbg_inspect() const override; diff --git a/include/natalie/method.hpp b/include/natalie/method.hpp index a5304e885..3b9b405c8 100644 --- a/include/natalie/method.hpp +++ b/include/natalie/method.hpp @@ -91,10 +91,10 @@ class Method : public Cell { const Optional &get_line() const { return m_line; } virtual void visit_children(Visitor &visitor) const override final { - visitor.enqueue(m_owner); - visitor.enqueue(m_env); - visitor.enqueue(m_self); - visitor.enqueue(m_original_method); + visitor.visit(m_owner); + visitor.visit(m_env); + visitor.visit(m_self); + visitor.visit(m_original_method); } virtual void gc_inspect(char *buf, size_t len) const override { diff --git a/include/natalie/method_object.hpp b/include/natalie/method_object.hpp index 765845877..3f14930ec 100644 --- a/include/natalie/method_object.hpp +++ b/include/natalie/method_object.hpp @@ -44,9 +44,9 @@ class MethodObject : public AbstractMethodObject { virtual void visit_children(Visitor &visitor) const override final { AbstractMethodObject::visit_children(visitor); - visitor.enqueue(m_object); - visitor.enqueue(m_method); - visitor.enqueue(m_method_missing_name); + visitor.visit(m_object); + visitor.visit(m_method); + visitor.visit(m_method_missing_name); } virtual void gc_inspect(char *buf, size_t len) const override { diff --git a/include/natalie/proc_object.hpp b/include/natalie/proc_object.hpp index 22d027a34..0945fadf0 100644 --- a/include/natalie/proc_object.hpp +++ b/include/natalie/proc_object.hpp @@ -62,7 +62,7 @@ class ProcObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_block); + visitor.visit(m_block); } virtual void gc_inspect(char *buf, size_t len) const override { diff --git a/include/natalie/range_object.hpp b/include/natalie/range_object.hpp index 66c4a2888..d7e1ef6bf 100644 --- a/include/natalie/range_object.hpp +++ b/include/natalie/range_object.hpp @@ -45,8 +45,8 @@ class RangeObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_begin); - visitor.enqueue(m_end); + visitor.visit(m_begin); + visitor.visit(m_end); } virtual String dbg_inspect() const override; diff --git a/include/natalie/rational_object.hpp b/include/natalie/rational_object.hpp index 74bb8ad78..8cceeab2d 100644 --- a/include/natalie/rational_object.hpp +++ b/include/natalie/rational_object.hpp @@ -50,8 +50,8 @@ class RationalObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_numerator); - visitor.enqueue(m_denominator); + visitor.visit(m_numerator); + visitor.visit(m_denominator); } virtual void gc_inspect(char *buf, size_t len) const override { diff --git a/include/natalie/regexp_object.hpp b/include/natalie/regexp_object.hpp index 601ab12d2..a56ec264c 100644 --- a/include/natalie/regexp_object.hpp +++ b/include/natalie/regexp_object.hpp @@ -187,7 +187,7 @@ class RegexpObject : public Object { void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); if (m_pattern) - visitor.enqueue(m_pattern); + visitor.visit(m_pattern); } private: diff --git a/include/natalie/string_object.hpp b/include/natalie/string_object.hpp index 1117707ae..40491b666 100644 --- a/include/natalie/string_object.hpp +++ b/include/natalie/string_object.hpp @@ -452,7 +452,7 @@ class StringObject : public Object { virtual void visit_children(Visitor &visitor) const override final { Object::visit_children(visitor); - visitor.enqueue(m_encoding.ptr()); + visitor.visit(m_encoding.ptr()); } virtual void gc_inspect(char *buf, size_t len) const override { diff --git a/include/natalie/string_unpacker.hpp b/include/natalie/string_unpacker.hpp index 222cc2ce6..96660668e 100644 --- a/include/natalie/string_unpacker.hpp +++ b/include/natalie/string_unpacker.hpp @@ -22,9 +22,9 @@ class StringUnpacker : public Cell { Value unpack1(Env *env); virtual void visit_children(Visitor &visitor) const override { - visitor.enqueue(m_source); - visitor.enqueue(m_unpacked_value); - visitor.enqueue(m_unpacked_array); + visitor.visit(m_source); + visitor.visit(m_unpacked_value); + visitor.visit(m_unpacked_array); } private: diff --git a/include/natalie/symbol_object.hpp b/include/natalie/symbol_object.hpp index 9f15ff711..394b12dc0 100644 --- a/include/natalie/symbol_object.hpp +++ b/include/natalie/symbol_object.hpp @@ -75,8 +75,8 @@ class SymbolObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_string); - visitor.enqueue(m_encoding); + visitor.visit(m_string); + visitor.visit(m_encoding); } virtual void gc_inspect(char *buf, size_t len) const override { @@ -91,7 +91,7 @@ class SymbolObject : public Object { static void visit_all_symbols(Visitor &visitor) { for (auto pair : s_symbols) { - visitor.enqueue(pair.second); + visitor.visit(pair.second); } } diff --git a/include/natalie/time_object.hpp b/include/natalie/time_object.hpp index 556593fd4..4b14d1c99 100644 --- a/include/natalie/time_object.hpp +++ b/include/natalie/time_object.hpp @@ -64,8 +64,8 @@ class TimeObject : public Object { virtual void visit_children(Visitor &visitor) const override { Object::visit_children(visitor); - visitor.enqueue(m_integer); - visitor.enqueue(m_subsec); + visitor.visit(m_integer); + visitor.visit(m_subsec); } virtual void gc_inspect(char *buf, size_t len) const override { diff --git a/include/natalie/unbound_method_object.hpp b/include/natalie/unbound_method_object.hpp index 9deea1c7f..93d03d334 100644 --- a/include/natalie/unbound_method_object.hpp +++ b/include/natalie/unbound_method_object.hpp @@ -52,8 +52,8 @@ class UnboundMethodObject : public AbstractMethodObject { virtual void visit_children(Visitor &visitor) const override final { AbstractMethodObject::visit_children(visitor); - visitor.enqueue(m_module_or_class); - visitor.enqueue(m_method); + visitor.visit(m_module_or_class); + visitor.visit(m_method); } virtual void gc_inspect(char *buf, size_t len) const override { diff --git a/src/constant.cpp b/src/constant.cpp index a4680fa5d..dc6057f63 100644 --- a/src/constant.cpp +++ b/src/constant.cpp @@ -10,9 +10,9 @@ void Constant::autoload(Env *env, Value self) { } void Constant::visit_children(Visitor &visitor) const { - visitor.enqueue(m_name); - visitor.enqueue(m_value); - visitor.enqueue(m_autoload_path); + visitor.visit(m_name); + visitor.visit(m_value); + visitor.visit(m_autoload_path); } } diff --git a/src/env.cpp b/src/env.cpp index befb81e9a..9ae4fefc7 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -387,15 +387,15 @@ Env *Env::non_block_env() { } void Env::visit_children(Visitor &visitor) const { - visitor.enqueue(m_vars); - visitor.enqueue(m_outer); - visitor.enqueue(m_block); - visitor.enqueue(m_this_block); - visitor.enqueue(m_caller); - visitor.enqueue(m_method); - visitor.enqueue(m_module); - visitor.enqueue(m_match); - visitor.enqueue(m_exception); - visitor.enqueue(m_catch); + visitor.visit(m_vars); + visitor.visit(m_outer); + visitor.visit(m_block); + visitor.visit(m_this_block); + visitor.visit(m_caller); + visitor.visit(m_method); + visitor.visit(m_module); + visitor.visit(m_match); + visitor.visit(m_exception); + visitor.visit(m_catch); } } diff --git a/src/exception_object.cpp b/src/exception_object.cpp index dde8ad491..902d5644f 100644 --- a/src/exception_object.cpp +++ b/src/exception_object.cpp @@ -209,11 +209,11 @@ bool ExceptionObject::is_local_jump_error_with_break_point(nat_int_t match_break void ExceptionObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); - visitor.enqueue(m_message); - visitor.enqueue(m_backtrace); - visitor.enqueue(m_backtrace_value); - visitor.enqueue(m_backtrace_locations); - visitor.enqueue(m_cause); + visitor.visit(m_message); + visitor.visit(m_backtrace); + visitor.visit(m_backtrace_value); + visitor.visit(m_backtrace_locations); + visitor.visit(m_cause); } } diff --git a/src/false_object.cpp b/src/false_object.cpp index 8b44c6f87..166dad41e 100644 --- a/src/false_object.cpp +++ b/src/false_object.cpp @@ -19,7 +19,7 @@ Value FalseObject::to_s(const Env *env) const { void FalseObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); if (s_string) - visitor.enqueue(s_string); + visitor.visit(s_string); } } diff --git a/src/fiber_object.cpp b/src/fiber_object.cpp index 2b7413c78..b788123a7 100644 --- a/src/fiber_object.cpp +++ b/src/fiber_object.cpp @@ -246,13 +246,13 @@ void FiberObject::swap_to_previous(Env *env, Args args) { void FiberObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); for (auto arg : m_args) - visitor.enqueue(arg); - visitor.enqueue(m_previous_fiber); - visitor.enqueue(m_error); - visitor.enqueue(m_block); - visitor.enqueue(m_storage); - visitor.enqueue(m_thread); - visitor.enqueue(m_thread_storage); + visitor.visit(arg); + visitor.visit(m_previous_fiber); + visitor.visit(m_error); + visitor.visit(m_block); + visitor.visit(m_storage); + visitor.visit(m_thread); + visitor.visit(m_thread_storage); visit_children_from_stack(visitor); } @@ -270,7 +270,7 @@ NO_SANITIZE_ADDRESS void FiberObject::visit_children_from_stack(Visitor &visitor for (char *ptr = reinterpret_cast(m_end_of_stack); ptr < m_start_of_stack; ptr += sizeof(intptr_t)) { Cell *potential_cell = *reinterpret_cast(ptr); if (Heap::the().is_a_heap_cell_in_use(potential_cell)) - visitor.enqueue(potential_cell); + visitor.visit(potential_cell); #ifdef __SANITIZE_ADDRESS__ visit_children_from_asan_fake_stack(visitor, potential_cell); #endif @@ -288,7 +288,7 @@ NO_SANITIZE_ADDRESS void FiberObject::visit_children_from_asan_fake_stack(Visito for (char *ptr = reinterpret_cast(begin); ptr < end; ptr += sizeof(intptr_t)) { Cell *potential_cell = *reinterpret_cast(ptr); if (Heap::the().is_a_heap_cell_in_use(potential_cell)) - visitor.enqueue(potential_cell); + visitor.visit(potential_cell); } } #else diff --git a/src/gc.cpp b/src/gc.cpp index d370fca74..f67b359d9 100644 --- a/src/gc.cpp +++ b/src/gc.cpp @@ -25,8 +25,8 @@ void Cell::operator delete(void *) { // object creation. We can just ignore that and let sweep() clean up the cell later. } -void Cell::Visitor::enqueue(Value val) { - enqueue(val.object_or_null()); +void Cell::Visitor::visit(Value val) { + visit(val.object_or_null()); } #ifdef __SANITIZE_ADDRESS__ @@ -122,16 +122,16 @@ void Heap::collect() { auto roots = gather_conservative_roots(); for (auto pair : roots) { - visitor.enqueue(pair.first); + visitor.visit(pair.first); } - visitor.enqueue(GlobalEnv::the()); - visitor.enqueue(NilObject::the()); - visitor.enqueue(TrueObject::the()); - visitor.enqueue(FalseObject::the()); - visitor.enqueue(tl_current_exception); + visitor.visit(GlobalEnv::the()); + visitor.visit(NilObject::the()); + visitor.visit(TrueObject::the()); + visitor.visit(FalseObject::the()); + visitor.visit(tl_current_exception); for (auto thread : ThreadObject::list()) - visitor.enqueue(thread); + visitor.visit(thread); // We don't collect symbols, but they each can have associated objects we do collect. SymbolObject::visit_all_symbols(visitor); diff --git a/src/global_env.cpp b/src/global_env.cpp index 3f7d544c1..2f18fe8ab 100644 --- a/src/global_env.cpp +++ b/src/global_env.cpp @@ -118,38 +118,38 @@ void GlobalEnv::set_interned_strings(StringObject **interned_strings, const size void GlobalEnv::visit_children(Visitor &visitor) const { for (auto pair : m_global_variables) { - visitor.enqueue(pair.first); - visitor.enqueue(pair.second); + visitor.visit(pair.first); + visitor.visit(pair.second); } for (size_t i = 0; i < EncodingCount; i++) - visitor.enqueue(m_Encodings[i]); + visitor.visit(m_Encodings[i]); for (auto pair : m_files) - visitor.enqueue(pair.first); + visitor.visit(pair.first); for (const auto &span : m_interned_strings) for (auto str : span) - visitor.enqueue(str); + visitor.visit(str); for (const auto &instance_eval_context : m_instance_eval_contexts) { - visitor.enqueue(instance_eval_context.caller_env); - visitor.enqueue(instance_eval_context.block_original_self); + visitor.visit(instance_eval_context.caller_env); + visitor.visit(instance_eval_context.block_original_self); } - visitor.enqueue(m_Array); - visitor.enqueue(m_BasicObject); - visitor.enqueue(m_Binding); - visitor.enqueue(m_Class); - visitor.enqueue(m_Complex); - visitor.enqueue(m_Float); - visitor.enqueue(m_Hash); - visitor.enqueue(m_Integer); - visitor.enqueue(m_Module); - visitor.enqueue(m_Object); - visitor.enqueue(m_Random); - visitor.enqueue(m_Rational); - visitor.enqueue(m_Regexp); - visitor.enqueue(m_String); - visitor.enqueue(m_Symbol); - visitor.enqueue(m_Time); - visitor.enqueue(m_main_obj); - visitor.enqueue(m_main_env); + visitor.visit(m_Array); + visitor.visit(m_BasicObject); + visitor.visit(m_Binding); + visitor.visit(m_Class); + visitor.visit(m_Complex); + visitor.visit(m_Float); + visitor.visit(m_Hash); + visitor.visit(m_Integer); + visitor.visit(m_Module); + visitor.visit(m_Object); + visitor.visit(m_Random); + visitor.visit(m_Rational); + visitor.visit(m_Regexp); + visitor.visit(m_String); + visitor.visit(m_Symbol); + visitor.visit(m_Time); + visitor.visit(m_main_obj); + visitor.visit(m_main_env); } } diff --git a/src/global_variable_info.cpp b/src/global_variable_info.cpp index 70cc87d00..1834baaf9 100644 --- a/src/global_variable_info.cpp +++ b/src/global_variable_info.cpp @@ -17,7 +17,7 @@ Value GlobalVariableInfo::object(Env *env) { } void GlobalVariableInfo::visit_children(Visitor &visitor) const { - visitor.enqueue(m_object); + visitor.visit(m_object); } } diff --git a/src/hash_object.cpp b/src/hash_object.cpp index e173848a1..5bfcdfc4d 100644 --- a/src/hash_object.cpp +++ b/src/hash_object.cpp @@ -703,13 +703,13 @@ Value HashObject::slice(Env *env, Args args) { void HashObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); for (auto pair : m_hashmap) { - visitor.enqueue(pair.first); - visitor.enqueue(pair.first->key); - visitor.enqueue(pair.first->val); - visitor.enqueue(pair.second); + visitor.visit(pair.first); + visitor.visit(pair.first->key); + visitor.visit(pair.first->val); + visitor.visit(pair.second); } - visitor.enqueue(m_default_value); - visitor.enqueue(m_default_proc); + visitor.visit(m_default_value); + visitor.visit(m_default_proc); } Value HashObject::compact(Env *env) { diff --git a/src/method_info.cpp b/src/method_info.cpp index 12c97db5b..3e10c75f9 100644 --- a/src/method_info.cpp +++ b/src/method_info.cpp @@ -3,7 +3,7 @@ namespace Natalie { void MethodInfo::visit_children(Cell::Visitor &visitor) { - visitor.enqueue(m_method); + visitor.visit(m_method); } } diff --git a/src/module_object.cpp b/src/module_object.cpp index 1a39c7529..4cc8a2d2b 100644 --- a/src/module_object.cpp +++ b/src/module_object.cpp @@ -1125,22 +1125,22 @@ Value ModuleObject::ruby2_keywords(Env *env, Value name) { void ModuleObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); - visitor.enqueue(m_env); - visitor.enqueue(m_superclass); + visitor.visit(m_env); + visitor.visit(m_superclass); for (auto pair : m_constants) { - visitor.enqueue(pair.first); - visitor.enqueue(pair.second); + visitor.visit(pair.first); + visitor.visit(pair.second); } for (auto pair : m_methods) { - visitor.enqueue(pair.first); + visitor.visit(pair.first); pair.second.visit_children(visitor); } for (auto pair : m_class_vars) { - visitor.enqueue(pair.first); - visitor.enqueue(pair.second); + visitor.visit(pair.first); + visitor.visit(pair.second); } for (auto module : m_included_modules) { - visitor.enqueue(module); + visitor.visit(module); } } diff --git a/src/nil_object.cpp b/src/nil_object.cpp index 322f064ed..25944e355 100644 --- a/src/nil_object.cpp +++ b/src/nil_object.cpp @@ -55,7 +55,7 @@ Value NilObject::inspect(const Env *env) const { void NilObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); if (s_string) - visitor.enqueue(s_string); + visitor.visit(s_string); } } diff --git a/src/object.cpp b/src/object.cpp index 94a3a0d25..91badda04 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -1341,13 +1341,13 @@ Value Object::enum_for(Env *env, const char *method, Args args) { } void Object::visit_children(Visitor &visitor) const { - visitor.enqueue(m_klass); - visitor.enqueue(m_singleton_class); - visitor.enqueue(m_owner); + visitor.visit(m_klass); + visitor.visit(m_singleton_class); + visitor.visit(m_owner); if (m_ivars) { for (auto pair : *m_ivars) { - visitor.enqueue(pair.first); - visitor.enqueue(pair.second); + visitor.visit(pair.first); + visitor.visit(pair.second); } } } diff --git a/src/thread/backtrace/location_object.cpp b/src/thread/backtrace/location_object.cpp index 60927e1d6..afb098c15 100644 --- a/src/thread/backtrace/location_object.cpp +++ b/src/thread/backtrace/location_object.cpp @@ -16,9 +16,9 @@ StringObject *LocationObject::to_s() const { void LocationObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); - visitor.enqueue(m_source_location); - visitor.enqueue(m_file); - visitor.enqueue(m_line); + visitor.visit(m_source_location); + visitor.visit(m_file); + visitor.visit(m_line); } } diff --git a/src/thread/mutex_object.cpp b/src/thread/mutex_object.cpp index 6265fec8b..8a51cc75e 100644 --- a/src/thread/mutex_object.cpp +++ b/src/thread/mutex_object.cpp @@ -107,8 +107,8 @@ bool MutexObject::is_owned() { void MutexObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); - visitor.enqueue(m_thread); - visitor.enqueue(m_fiber); + visitor.visit(m_thread); + visitor.visit(m_fiber); } } diff --git a/src/thread_group_object.cpp b/src/thread_group_object.cpp index b98c6b400..cb36ca5e9 100644 --- a/src/thread_group_object.cpp +++ b/src/thread_group_object.cpp @@ -40,9 +40,9 @@ ArrayObject *ThreadGroupObject::list() { void ThreadGroupObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); - visitor.enqueue(m_default); + visitor.visit(m_default); for (auto thread : m_threads) - visitor.enqueue(thread); + visitor.visit(thread); } void ThreadGroupObject::initialize_default() { diff --git a/src/thread_object.cpp b/src/thread_object.cpp index 87b84920d..784ffd4c0 100644 --- a/src/thread_object.cpp +++ b/src/thread_object.cpp @@ -622,19 +622,19 @@ void ThreadObject::unlock_mutexes() const { void ThreadObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); for (auto arg : m_args.vector()) - visitor.enqueue(arg); - visitor.enqueue(m_block); - visitor.enqueue(m_exception); - visitor.enqueue(m_value); - visitor.enqueue(m_thread_variables); + visitor.visit(arg); + visitor.visit(m_block); + visitor.visit(m_exception); + visitor.visit(m_value); + visitor.visit(m_thread_variables); for (auto pair : m_mutexes) - visitor.enqueue(pair.first); - visitor.enqueue(m_fiber_scheduler); - visitor.enqueue(s_thread_kill_class); - visitor.enqueue(m_group); + visitor.visit(pair.first); + visitor.visit(m_fiber_scheduler); + visitor.visit(s_thread_kill_class); + visitor.visit(m_group); - visitor.enqueue(m_current_fiber); - visitor.enqueue(m_main_fiber); + visitor.visit(m_current_fiber); + visitor.visit(m_main_fiber); // If this thread is Dead, then it's possible the OS has already reclaimed // the stack space. We shouldn't have any remaining variables on the stack @@ -825,7 +825,7 @@ NO_SANITIZE_ADDRESS void ThreadObject::visit_children_from_stack(Visitor &visito for (char *ptr = reinterpret_cast(m_end_of_stack); ptr < m_start_of_stack; ptr += sizeof(intptr_t)) { Cell *potential_cell = *reinterpret_cast(ptr); if (Heap::the().is_a_heap_cell_in_use(potential_cell)) - visitor.enqueue(potential_cell); + visitor.visit(potential_cell); #ifdef __SANITIZE_ADDRESS__ visit_children_from_asan_fake_stack(visitor, potential_cell); #endif @@ -846,7 +846,7 @@ NO_SANITIZE_ADDRESS void ThreadObject::visit_children_from_asan_fake_stack(Visit for (char *ptr = reinterpret_cast(begin); ptr < end; ptr += sizeof(intptr_t)) { Cell *potential_cell = *reinterpret_cast(ptr); if (Heap::the().is_a_heap_cell_in_use(potential_cell)) - visitor.enqueue(potential_cell); + visitor.visit(potential_cell); } } #else @@ -859,7 +859,7 @@ NO_SANITIZE_ADDRESS void ThreadObject::visit_children_from_context(Visitor &visi if (!potential_cell) continue; if (Heap::the().is_a_heap_cell_in_use(potential_cell)) - visitor.enqueue(potential_cell); + visitor.visit(potential_cell); } } diff --git a/src/throw_catch_exception.cpp b/src/throw_catch_exception.cpp index d81fe77e5..9df5d8095 100644 --- a/src/throw_catch_exception.cpp +++ b/src/throw_catch_exception.cpp @@ -4,8 +4,8 @@ namespace Natalie { void ThrowCatchException::visit_children(Visitor &visitor) const { - visitor.enqueue(m_name); - visitor.enqueue(m_value); + visitor.visit(m_name); + visitor.visit(m_value); } } diff --git a/src/true_object.cpp b/src/true_object.cpp index 81f3b2a10..f21e31ef0 100644 --- a/src/true_object.cpp +++ b/src/true_object.cpp @@ -23,7 +23,7 @@ Value TrueObject::to_s(const Env *env) const { void TrueObject::visit_children(Visitor &visitor) const { Object::visit_children(visitor); if (s_string) - visitor.enqueue(s_string); + visitor.visit(s_string); } } diff --git a/test/gc_lint.rb b/test/gc_lint.rb index cf812311c..121dd00a2 100644 --- a/test/gc_lint.rb +++ b/test/gc_lint.rb @@ -163,7 +163,7 @@ def verify_visited(klass, type, name) details = @classes.fetch(klass) if garbage_collected?(type) if (method_lines = details[:visit_children_method]) - visits_directly = method_lines.grep(/^\s*visitor\.enqueue\(&?#{name}/).any? + visits_directly = method_lines.grep(/^\s*visitor\.visit\(&?#{name}/).any? loops_over = method_lines.grep(/for\s*\(.*:\s*\*?#{name}\)/).any? unless visits_directly || loops_over @errors << "#{klass}'s visit_children() method does not visit #{name} (type #{type})!"