Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mkornaukhov03 committed Dec 27, 2024
1 parent 725f1a0 commit 1dfc11e
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 29 deletions.
6 changes: 0 additions & 6 deletions compiler/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compiler/data/function-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FunctionData {
std::vector<VarPtr> local_var_ids, global_var_ids, static_var_ids, param_ids;
std::unordered_set<VarPtr> *bad_vars = nullptr; // for check ub and safe operations wrapper, see comments in check-ub.cpp
std::set<VarPtr> implicit_const_var_ids, explicit_const_var_ids, explicit_header_const_var_ids;
std::vector<FunctionPtr> dep; // should wait on them in some passes; may be deadlock?
std::vector<FunctionPtr> dep;
std::set<ClassPtr> class_dep;
std::set<ClassPtr> exceptions_thrown; // exceptions that can be thrown by this function
bool tl_common_h_dep = false;
Expand Down
2 changes: 1 addition & 1 deletion compiler/data/var-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#pragma once

#include "common/wrappers/copyable-atomic.h"
#include <cstdint>
#include <string>

#include "common/wrappers/copyable-atomic.h"
#include "compiler/data/class-members.h"
#include "compiler/debug.h"
#include "compiler/inferring/var-node.h"
Expand Down
4 changes: 1 addition & 3 deletions compiler/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,6 @@ VertexAdaptor<op_function> GenTree::get_function(bool is_lambda, const PhpDocCom
cur_function->root->cmd_ref() = VertexAdaptor<op_seq>::create();
}

// think about this place later
auto resp = cur_function->root;

// the function is ready, register it;
Expand All @@ -1619,8 +1618,7 @@ VertexAdaptor<op_function> 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;
Expand Down
4 changes: 2 additions & 2 deletions compiler/inferring/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#pragma once

#include "common/wrappers/copyable-atomic.h"
#include <atomic>
#include <string>
#include <forward_list>

#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 {
Expand Down
6 changes: 3 additions & 3 deletions compiler/inferring/type-node.cpp
Original file line number Diff line number Diff line change
@@ -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 <atomic>

#include "compiler/inferring/type-data.h"
#include "compiler/inferring/type-node.h"
#include "compiler/stage.h"
#include <atomic>

std::string tinf::TypeNode::get_description() {
return "TypeNode at " + location_.as_human_readable() + " : " + type_.load(std::memory_order_relaxed)->as_human_readable();
Expand Down
2 changes: 1 addition & 1 deletion compiler/pipes/check-func-calls-and-vararg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ VertexPtr CheckFuncCallsAndVarargPass::on_func_call(VertexAdaptor<op_func_call>
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()) {
Expand Down
3 changes: 2 additions & 1 deletion compiler/pipes/collect-const-vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

#include "compiler/pipes/collect-const-vars.h"

#include <atomic>

#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 <atomic>

namespace {

Expand Down
2 changes: 1 addition & 1 deletion compiler/pipes/deduce-implicit-types-and-casts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ void DeduceImplicitTypesAndCastsPass::on_func_call(VertexAdaptor<op_func_call> 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<T>`, 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)
Expand Down
2 changes: 1 addition & 1 deletion compiler/pipes/sort-and-inherit-classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ void SortAndInheritClassesF::execute(ClassPtr klass, MultipleDataStreams<Functio
}

node->data.waiting.clear();
node->data.done = true; // write
node->data.done = true;
}

void SortAndInheritClassesF::check_on_finish(DataStream<FunctionPtr> &os) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/pipes/sort-and-inherit-classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#pragma once

#include "common/wrappers/copyable-atomic.h"
#include <forward_list>

#include "common/wrappers/copyable-atomic.h"
#include "compiler/data/class-members.h"
#include "compiler/data/data_ptr.h"
#include "compiler/threading/data-stream.h"
Expand Down
2 changes: 1 addition & 1 deletion compiler/scheduler/scheduler-base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "compiler/scheduler/scheduler-base.h"

#include <cassert>
#include <atomic>
#include <cassert>

std::atomic_int tasks_before_sync_node = 0;

Expand Down
2 changes: 1 addition & 1 deletion compiler/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include "compiler/scheduler/scheduler.h"

#include "compiler/scheduler/scheduler-base.h"
#include <atomic>
#include <vector>

#include "compiler/scheduler/scheduler-base.h"
#include "compiler/scheduler/task.h"
#include "compiler/threading/thread-id.h"
#include "compiler/threading/tls.h"
Expand Down
6 changes: 2 additions & 4 deletions compiler/type-hint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@

#include "compiler/type-hint.h"

#include "compiler/threading/locks.h"
#include <atomic>
#include <mutex>

#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]
Expand Down
2 changes: 0 additions & 2 deletions compiler/type-hint.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#pragma once

#include "compiler/threading/locks.h"
#include <string>
#include <string_view>
#include <vector>
Expand All @@ -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;
Expand Down

0 comments on commit 1dfc11e

Please sign in to comment.