From 1dfc11e9eb48a1afc9dbaf134b102461c283673b Mon Sep 17 00:00:00 2001 From: Mikhail Kornaukhov Date: Fri, 27 Dec 2024 16:15:02 +0300 Subject: [PATCH] cleanup --- compiler/compiler.cmake | 6 ------ compiler/data/function-data.h | 2 +- compiler/data/var-data.h | 2 +- compiler/gentree.cpp | 4 +--- compiler/inferring/node.h | 4 ++-- compiler/inferring/type-node.cpp | 6 +++--- compiler/pipes/check-func-calls-and-vararg.cpp | 2 +- compiler/pipes/collect-const-vars.cpp | 3 ++- compiler/pipes/deduce-implicit-types-and-casts.cpp | 2 +- compiler/pipes/sort-and-inherit-classes.cpp | 2 +- compiler/pipes/sort-and-inherit-classes.h | 2 +- compiler/scheduler/scheduler-base.cpp | 2 +- compiler/scheduler/scheduler.cpp | 2 +- compiler/type-hint.cpp | 6 ++---- compiler/type-hint.h | 2 -- 15 files changed, 18 insertions(+), 29 deletions(-) diff --git a/compiler/compiler.cmake b/compiler/compiler.cmake index 70099438ee..9652f8d83c 100644 --- a/compiler/compiler.cmake +++ b/compiler/compiler.cmake @@ -285,12 +285,6 @@ target_link_libraries(kphp2cpp PRIVATE ${COMPILER_LIBS}) target_link_options(kphp2cpp PRIVATE ${NO_PIE}) set_target_properties(kphp2cpp PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BIN_DIR}) -# todo make as option, like asan -# target_compile_options(kphp2cpp PUBLIC "-fsanitize=thread" "-fPIC") -# target_compile_options(kphp2cpp_src PUBLIC "-fsanitize=thread" "-fPIC") -# target_link_options(kphp2cpp PUBLIC "-fsanitize=thread" "-fPIC") -# target_link_options(kphp2cpp_src PUBLIC "-fsanitize=thread" "-fPIC") - add_dependencies(kphp2cpp_src auto_vertices_generation_target) if(COMPILE_RUNTIME_LIGHT) add_compile_definitions(RUNTIME_LIGHT) diff --git a/compiler/data/function-data.h b/compiler/data/function-data.h index dcda33fc75..06e637d1d5 100644 --- a/compiler/data/function-data.h +++ b/compiler/data/function-data.h @@ -56,7 +56,7 @@ class FunctionData { std::vector local_var_ids, global_var_ids, static_var_ids, param_ids; std::unordered_set *bad_vars = nullptr; // for check ub and safe operations wrapper, see comments in check-ub.cpp std::set implicit_const_var_ids, explicit_const_var_ids, explicit_header_const_var_ids; - std::vector dep; // should wait on them in some passes; may be deadlock? + std::vector dep; std::set class_dep; std::set exceptions_thrown; // exceptions that can be thrown by this function bool tl_common_h_dep = false; diff --git a/compiler/data/var-data.h b/compiler/data/var-data.h index ffab6536e4..d05a308bcd 100644 --- a/compiler/data/var-data.h +++ b/compiler/data/var-data.h @@ -4,10 +4,10 @@ #pragma once -#include "common/wrappers/copyable-atomic.h" #include #include +#include "common/wrappers/copyable-atomic.h" #include "compiler/data/class-members.h" #include "compiler/debug.h" #include "compiler/inferring/var-node.h" diff --git a/compiler/gentree.cpp b/compiler/gentree.cpp index f6aa9aab90..5cb32f4732 100644 --- a/compiler/gentree.cpp +++ b/compiler/gentree.cpp @@ -1607,7 +1607,6 @@ VertexAdaptor GenTree::get_function(bool is_lambda, const PhpDocCom cur_function->root->cmd_ref() = VertexAdaptor::create(); } - // think about this place later auto resp = cur_function->root; // the function is ready, register it; @@ -1619,8 +1618,7 @@ VertexAdaptor GenTree::get_function(bool is_lambda, const PhpDocCom || cur_function->modifiers.is_instance() || cur_function->is_lambda() || kphp_required_flag; - G->register_and_require_function(cur_function, parsed_os, auto_require); // here we pass function further - // Next passes with cur function may ends before this line + G->register_and_require_function(cur_function, parsed_os, auto_require); // pass function further } return resp; diff --git a/compiler/inferring/node.h b/compiler/inferring/node.h index 2c33ca9b0e..27495e067b 100644 --- a/compiler/inferring/node.h +++ b/compiler/inferring/node.h @@ -4,14 +4,14 @@ #pragma once -#include "common/wrappers/copyable-atomic.h" #include #include #include +#include "common/wrappers/copyable-atomic.h" #include "compiler/debug.h" -#include "compiler/location.h" #include "compiler/inferring/type-data.h" +#include "compiler/location.h" #include "compiler/threading/locks.h" namespace tinf { diff --git a/compiler/inferring/type-node.cpp b/compiler/inferring/type-node.cpp index 9fa57f7255..cf196e06af 100644 --- a/compiler/inferring/type-node.cpp +++ b/compiler/inferring/type-node.cpp @@ -1,12 +1,12 @@ // Compiler for PHP (aka KPHP) -// Copyright (c) 2020 LLC «V Kontakte» +// Copyright (c) 2024 LLC «V Kontakte» // Distributed under the GPL v3 License, see LICENSE.notice.txt -#include "compiler/inferring/type-node.h" +#include #include "compiler/inferring/type-data.h" +#include "compiler/inferring/type-node.h" #include "compiler/stage.h" -#include std::string tinf::TypeNode::get_description() { return "TypeNode at " + location_.as_human_readable() + " : " + type_.load(std::memory_order_relaxed)->as_human_readable(); diff --git a/compiler/pipes/check-func-calls-and-vararg.cpp b/compiler/pipes/check-func-calls-and-vararg.cpp index 544c6fddb3..9ac0736151 100644 --- a/compiler/pipes/check-func-calls-and-vararg.cpp +++ b/compiler/pipes/check-func-calls-and-vararg.cpp @@ -250,7 +250,7 @@ VertexPtr CheckFuncCallsAndVarargPass::on_func_call(VertexAdaptor fmt_format("Can not call an abstract method {}()", f->as_human_readable())); } - VertexRange func_params = f->get_params(); // read here, f is concurrently processed in this pass + VertexRange func_params = f->get_params(); VertexRange call_params = call->args(); if (call_params.size() < func_params.size()) { diff --git a/compiler/pipes/collect-const-vars.cpp b/compiler/pipes/collect-const-vars.cpp index 3ef73acd2a..f50880264d 100644 --- a/compiler/pipes/collect-const-vars.cpp +++ b/compiler/pipes/collect-const-vars.cpp @@ -4,13 +4,14 @@ #include "compiler/pipes/collect-const-vars.h" +#include + #include "compiler/data/src-file.h" #include "compiler/vertex-util.h" #include "compiler/data/var-data.h" #include "compiler/const-manipulations.h" #include "compiler/compiler-core.h" #include "compiler/name-gen.h" -#include namespace { diff --git a/compiler/pipes/deduce-implicit-types-and-casts.cpp b/compiler/pipes/deduce-implicit-types-and-casts.cpp index fe6d99bad1..61e4c3426d 100644 --- a/compiler/pipes/deduce-implicit-types-and-casts.cpp +++ b/compiler/pipes/deduce-implicit-types-and-casts.cpp @@ -605,7 +605,7 @@ void DeduceImplicitTypesAndCastsPass::on_func_call(VertexAdaptor c FunctionPtr f_called = call->func_id; auto call_args = call->args(); - auto f_called_params = f_called->get_params(); // f_called is concurrently processed in TransformToSmartInstanceofPass + auto f_called_params = f_called->get_params(); // if we are calling `f`, then `f` has not been instantiated yet at this point, so we have a generic func call // at first, we need to know all generic types (call->reifiedTs) diff --git a/compiler/pipes/sort-and-inherit-classes.cpp b/compiler/pipes/sort-and-inherit-classes.cpp index 9f2588f30e..9338ed8d38 100644 --- a/compiler/pipes/sort-and-inherit-classes.cpp +++ b/compiler/pipes/sort-and-inherit-classes.cpp @@ -367,7 +367,7 @@ void SortAndInheritClassesF::execute(ClassPtr klass, MultipleDataStreamsdata.waiting.clear(); - node->data.done = true; // write + node->data.done = true; } void SortAndInheritClassesF::check_on_finish(DataStream &os) { diff --git a/compiler/pipes/sort-and-inherit-classes.h b/compiler/pipes/sort-and-inherit-classes.h index 41c507d752..8266f9a64c 100644 --- a/compiler/pipes/sort-and-inherit-classes.h +++ b/compiler/pipes/sort-and-inherit-classes.h @@ -4,9 +4,9 @@ #pragma once -#include "common/wrappers/copyable-atomic.h" #include +#include "common/wrappers/copyable-atomic.h" #include "compiler/data/class-members.h" #include "compiler/data/data_ptr.h" #include "compiler/threading/data-stream.h" diff --git a/compiler/scheduler/scheduler-base.cpp b/compiler/scheduler/scheduler-base.cpp index 5f4d695ded..987aab2ac1 100644 --- a/compiler/scheduler/scheduler-base.cpp +++ b/compiler/scheduler/scheduler-base.cpp @@ -4,8 +4,8 @@ #include "compiler/scheduler/scheduler-base.h" -#include #include +#include std::atomic_int tasks_before_sync_node = 0; diff --git a/compiler/scheduler/scheduler.cpp b/compiler/scheduler/scheduler.cpp index 5f3d7bbeef..8410efb36e 100644 --- a/compiler/scheduler/scheduler.cpp +++ b/compiler/scheduler/scheduler.cpp @@ -4,10 +4,10 @@ #include "compiler/scheduler/scheduler.h" -#include "compiler/scheduler/scheduler-base.h" #include #include +#include "compiler/scheduler/scheduler-base.h" #include "compiler/scheduler/task.h" #include "compiler/threading/thread-id.h" #include "compiler/threading/tls.h" diff --git a/compiler/type-hint.cpp b/compiler/type-hint.cpp index 132224a4ee..12dc286581 100644 --- a/compiler/type-hint.cpp +++ b/compiler/type-hint.cpp @@ -4,18 +4,16 @@ #include "compiler/type-hint.h" -#include "compiler/threading/locks.h" #include #include #include "common/php-functions.h" - #include "compiler/data/class-data.h" -#include "compiler/data/function-data.h" #include "compiler/data/ffi-data.h" +#include "compiler/data/function-data.h" #include "compiler/lambda-utils.h" #include "compiler/name-gen.h" - +#include "compiler/threading/locks.h" /** * This class stores a big hashtable [hash => TypeHint] diff --git a/compiler/type-hint.h b/compiler/type-hint.h index a771f71a54..03c34f921d 100644 --- a/compiler/type-hint.h +++ b/compiler/type-hint.h @@ -4,7 +4,6 @@ #pragma once -#include "compiler/threading/locks.h" #include #include #include @@ -13,7 +12,6 @@ #include "compiler/debug.h" #include "compiler/inferring/primitive-type.h" - // do not confuse TypeHint with TypeData! // TypeData is a part of _type inferring_; it's mutable and plain, it represents current inferred state of every vertex class TypeData;