Skip to content

Commit

Permalink
Move runtime-core into runtime-common (#1126)
Browse files Browse the repository at this point in the history
  • Loading branch information
apolyakov authored Oct 24, 2024
1 parent 09783d0 commit 5e4b58a
Show file tree
Hide file tree
Showing 266 changed files with 398 additions and 406 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ include(${COMMON_DIR}/common.cmake)
include(${COMMON_DIR}/tl/tl.cmake)
include(${COMMON_DIR}/unicode/unicode.cmake)

include(${BASE_DIR}/runtime-core/runtime-core.cmake)
include(${RUNTIME_COMMON_DIR}/runtime-common.cmake)

if(COMPILE_RUNTIME_LIGHT)
include(${BASE_DIR}/runtime-light/runtime-light.cmake)
file(GLOB EXCLUDE_FILES "runtime/*")
Expand All @@ -51,6 +52,7 @@ else()
include(${BASE_DIR}/server/server.cmake)
file(GLOB EXCLUDE_FILES "runtime-light/*")
endif()

include(${BASE_DIR}/compiler/compiler.cmake)
include(${BASE_DIR}/tests/tests.cmake)

Expand Down Expand Up @@ -85,7 +87,7 @@ endif ()

install(DIRECTORY ${COMMON_DIR}
${BASE_DIR}/runtime
${BASE_DIR}/runtime-core
${RUNTIME_COOMON_DIR}
${BASE_DIR}/server
${BASE_DIR}/third-party
COMPONENT KPHP
Expand Down
2 changes: 1 addition & 1 deletion cmake/init-global-vars.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(BIN_DIR ${OBJS_DIR}/bin)
set(GENERATED_DIR "${OBJS_DIR}/generated")
set(AUTO_DIR "${GENERATED_DIR}/auto")
set(RUNTIME_LIGHT_DIR "${BASE_DIR}/runtime-light")
set(RUNTIME_CORE_DIR "${BASE_DIR}/runtime-core")
set(RUNTIME_COMMON_DIR "${BASE_DIR}/runtime-common")

if(APPLE)
set(CURL_LIB curl)
Expand Down
15 changes: 7 additions & 8 deletions compiler/compiler-core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ const Index &CompilerCore::get_runtime_index() {
}

const Index &CompilerCore::get_runtime_core_index() {
return runtime_core_sources_index;
return runtime_common_sources_index;
}

const Index &CompilerCore::get_common_index() {
Expand All @@ -668,9 +668,9 @@ void CompilerCore::init_dest_dir() {
cpp_dir = cpp_index.get_dir();
}

static std::vector<std::string> get_runtime_core_sources() {
static std::vector<std::string> get_runtime_common_sources() {
#ifdef RUNTIME_LIGHT
return split(RUNTIME_CORE_SOURCES, ';');
return split(RUNTIME_COMMON_SOURCES, ';');
#else
return {};
#endif
Expand All @@ -693,17 +693,16 @@ static std::vector<std::string> get_common_sources() {
}

void CompilerCore::init_runtime_and_common_srcs_dir() {
runtime_core_sources_dir = settings().runtime_and_common_src.get() + "runtime-core/";
runtime_core_sources_index.sync_with_dir(runtime_core_sources_dir);
runtime_core_sources_dir = runtime_core_sources_index.get_dir();
runtime_core_sources_index.filter_with_whitelist(get_runtime_core_sources());
runtime_common_sources_dir = settings().runtime_and_common_src.get() + "runtime-common/";
runtime_common_sources_index.sync_with_dir(runtime_common_sources_dir);
runtime_common_sources_dir = runtime_common_sources_index.get_dir();
runtime_common_sources_index.filter_with_whitelist(get_runtime_common_sources());

runtime_sources_dir = settings().runtime_and_common_src.get() + "runtime-light/";
runtime_sources_index.sync_with_dir(runtime_sources_dir);
runtime_sources_dir = runtime_sources_index.get_dir(); // As in init_dest_dir, IDK what is it for
runtime_sources_index.filter_with_whitelist(get_runtime_sources());


common_sources_dir = settings().runtime_and_common_src.get() + "common/";
common_sources_index.sync_with_dir(common_sources_dir);
common_sources_dir = common_sources_index.get_dir(); // As in init_dest_dir, IDK what is it for
Expand Down
4 changes: 2 additions & 2 deletions compiler/compiler-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum class OutputMode {
class CompilerCore {
private:
Index cpp_index;
Index runtime_core_sources_index;
Index runtime_common_sources_index;
Index runtime_sources_index;
Index common_sources_index;
TSHashTable<SrcFilePtr> file_ht;
Expand Down Expand Up @@ -68,7 +68,7 @@ class CompilerCore {
std::string cpp_dir;

// Don't like that, handle in another way
std::string runtime_core_sources_dir;
std::string runtime_common_sources_dir;
std::string runtime_sources_dir;
std::string common_sources_dir;

Expand Down
2 changes: 1 addition & 1 deletion compiler/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (COMPILE_RUNTIME_LIGHT)
prepend(RUNTIME_BUILD_INFO ${KPHP_COMPILER_AUTO_DIR}/
common_sources.h
runtime_sources.h
runtime_core_sources.h
runtime_common_sources.h
runtime_compile_flags.h)
endif()

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

#include "auto/compiler/common_sources.h"
#include "auto/compiler/runtime_compile_flags.h"
#include "auto/compiler/runtime_core_sources.h"
#include "auto/compiler/runtime_common_sources.h"
#include "auto/compiler/runtime_sources.h"

#endif
3 changes: 3 additions & 0 deletions compiler/runtime_common_sources.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#define RUNTIME_COMMON_SOURCES "${RUNTIME_COMMON_SOURCES_FOR_COMP}"
3 changes: 0 additions & 3 deletions compiler/runtime_core_sources.h.in

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include <cstddef>
#include "runtime-core/memory-resource/unsynchronized_pool_resource.h"
#include "runtime-common/core/memory-resource/unsynchronized_pool_resource.h"


struct RuntimeAllocator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <cstddef>

#include "runtime-core/allocator/runtime-allocator.h"
#include "runtime-common/core/allocator/runtime-allocator.h"

class ScriptAllocatorManaged {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "common/php-functions.h"

#include "runtime-core/allocator/script-allocator-managed.h"
#include "runtime-common/core/allocator/script-allocator-managed.h"

class abstract_refcountable_php_interface : public ScriptAllocatorManaged {
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "runtime-core/utils/migration-php8.h"
#include "runtime-common/core/utils/migration-php8.h"

#ifndef INCLUDED_FROM_KPHP_CORE
#error "this file must be included only from runtime-core.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include "runtime-core/core-types/decl/array_iterator.h"
#include "runtime-core/include.h"
#include "runtime-common/core/core-types/decl/array_iterator.h"
#include "runtime-common/core/include.h"

#ifndef INCLUDED_FROM_KPHP_CORE
#error "this file must be included only from runtime-core.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "common/type_traits/list_of_types.h"
#include "common/sanitizer.h"

#include "runtime-core/core-types/decl/declarations.h"
#include "runtime-common/core/core-types/decl/declarations.h"

template<class T>
class array_iterator {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include "common/smart_ptrs/intrusive_ptr.h"
#include "runtime-core/class-instance/refcountable-php-classes.h"
#include "runtime-common/core/class-instance/refcountable-php-classes.h"


#ifndef INCLUDED_FROM_KPHP_CORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "common/type_traits/is_constructible.h"
#include "common/type_traits/list_of_types.h"

#include "runtime-core/utils/kphp-assert-core.h"
#include "runtime-core/core-types/decl/declarations.h"
#include "runtime-common/core/utils/kphp-assert-core.h"
#include "runtime-common/core/core-types/decl/declarations.h"

template<class T>
class Optional;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the GPL v3 License, see LICENSE.notice.txt

#include "common/wrappers/likely.h"
#include "runtime-core/runtime-core.h"
#include "runtime-common/core/runtime-core.h"

void mixed::copy_from(const mixed &other) {
switch (other.get_type()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "common/algorithms/find.h"
#include "common/smart_ptrs/intrusive_ptr.h"

#include "runtime-core/utils/migration-php8.h"
#include "runtime-core/class-instance/refcountable-php-classes.h"
#include "runtime-common/core/utils/migration-php8.h"
#include "runtime-common/core/class-instance/refcountable-php-classes.h"

#ifndef INCLUDED_FROM_KPHP_CORE
#error "this file must be included only from runtime-core.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#pragma once
#include <type_traits>

#include "runtime-core/include.h"
#include "runtime-core/runtime-core.h"
#include "runtime-common/core/include.h"
#include "runtime-common/core/runtime-core.h"

namespace impl_ {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) 2021 LLC «V Kontakte»
// Distributed under the GPL v3 License, see LICENSE.notice.txt

#include "runtime-core/runtime-core.h"
#include "runtime-common/core/runtime-core.h"

// Don't move this destructor to the headers, it spoils addr2line traces
string::~string() noexcept {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include "common/algorithms/simd-int-to-string.h"

#include "runtime-core/utils/migration-php8.h"
#include "runtime-core/core-types/definition/string_cache.h"
#include "runtime-common/core/utils/migration-php8.h"
#include "runtime-common/core/core-types/definition/string_cache.h"

#ifndef INCLUDED_FROM_KPHP_CORE
#error "this file must be included only from runtime-core.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) 2020 LLC «V Kontakte»
// Distributed under the GPL v3 License, see LICENSE.notice.txt

#include "runtime-core/runtime-core.h"
#include "runtime-common/core/runtime-core.h"

string_buffer::string_buffer(string::size_type buffer_len) noexcept:
buffer_end(static_cast<char *>(RuntimeAllocator::current().alloc_global_memory(buffer_len))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) 2020 LLC «V Kontakte»
// Distributed under the GPL v3 License, see LICENSE.notice.txt

#include "runtime-core/runtime-core.h"
#include "runtime-common/core/runtime-core.h"

constexpr auto string_cache::constexpr_make_large_ints() noexcept {
return constexpr_make_ints(std::make_index_sequence<cached_int_max() / 10>{});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "common/php-functions.h"

#include "runtime-core/runtime-core.h"
#include "runtime-common/core/runtime-core.h"

class string_cache {
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include "common/type_traits/list_of_types.h"

#include "runtime-core/core-types/decl/declarations.h"
#include "runtime-core/core-types/decl/optional.h"
#include "runtime-core/core-types/decl/shape.h"
#include "runtime-common/core/core-types/decl/declarations.h"
#include "runtime-common/core/core-types/decl/optional.h"
#include "runtime-common/core/core-types/decl/shape.h"

template<typename>
struct is_array : std::false_type {
Expand Down
10 changes: 10 additions & 0 deletions runtime-common/core/core.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prepend(CORE_UTILS core/utils/ migration-php8.cpp)

prepend(CORE_TYPES core/core-types/definition/ mixed.cpp string.cpp
string_buffer.cpp string_cache.cpp)

prepend(CORE_MEMORY_RESOURCE core/memory-resource/
details/memory_chunk_tree.cpp details/memory_ordered_chunk_list.cpp
monotonic_buffer_resource.cpp unsynchronized_pool_resource.cpp)

set(CORE_SRC ${CORE_UTILS} ${CORE_TYPES} ${CORE_MEMORY_RESOURCE})
8 changes: 4 additions & 4 deletions runtime-core/include.h → runtime-common/core/include.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include "common/wrappers/likely.h"

#include "common/php-functions.h"
#include "runtime-core/core-types/decl/declarations.h"
#include "runtime-core/core-types/kphp_type_traits.h"
#include "runtime-core/core-types/decl/optional.h"
#include "runtime-core/utils/kphp-assert-core.h"
#include "runtime-common/core/core-types/decl/declarations.h"
#include "runtime-common/core/core-types/kphp_type_traits.h"
#include "runtime-common/core/core-types/decl/optional.h"
#include "runtime-common/core/utils/kphp-assert-core.h"

#define COMMA ,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <memory>

#include "runtime-core/memory-resource/memory_resource.h"
#include "runtime-common/core/memory-resource/memory_resource.h"

namespace memory_resource {
namespace details {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <new>
#include <utility>

#include "runtime-core/memory-resource/details/memory_ordered_chunk_list.h"
#include "runtime-core/utils/kphp-assert-core.h"
#include "runtime-common/core/memory-resource/details/memory_ordered_chunk_list.h"
#include "runtime-common/core/utils/kphp-assert-core.h"

namespace memory_resource {
namespace details {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "common/mixin/not_copyable.h"

#include "runtime-core/memory-resource/memory_resource.h"
#include "runtime-common/core/memory-resource/memory_resource.h"

namespace memory_resource {
namespace details {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) 2020 LLC «V Kontakte»
// Distributed under the GPL v3 License, see LICENSE.notice.txt

#include "runtime-core/memory-resource/details/memory_ordered_chunk_list.h"
#include "runtime-common/core/memory-resource/details/memory_ordered_chunk_list.h"

#include <algorithm>
#include <cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include "common/mixin/not_copyable.h"

#include "runtime-core/memory-resource/memory_resource.h"
#include "runtime-core/utils/kphp-assert-core.h"
#include "runtime-common/core/memory-resource/memory_resource.h"
#include "runtime-common/core/utils/kphp-assert-core.h"

namespace memory_resource {
namespace details {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <cstring>

#include "runtime-core/memory-resource/memory_resource.h"
#include "runtime-common/core/memory-resource/memory_resource.h"

namespace memory_resource {
namespace details {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) 2020 LLC «V Kontakte»
// Distributed under the GPL v3 License, see LICENSE.notice.txt

#include "runtime-core/memory-resource/monotonic_buffer_resource.h"
#include "runtime-common/core/memory-resource/monotonic_buffer_resource.h"

namespace memory_resource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include "common/mixin/not_copyable.h"
#include "common/wrappers/likely.h"

#include "runtime-core/memory-resource/details/universal_reallocate.h"
#include "runtime-core/memory-resource/memory_resource.h"
#include "runtime-core/utils/kphp-assert-core.h"
#include "runtime-common/core/memory-resource/details/universal_reallocate.h"
#include "runtime-common/core/memory-resource/memory_resource.h"
#include "runtime-common/core/utils/kphp-assert-core.h"

namespace memory_resource {

Expand Down
Loading

0 comments on commit 5e4b58a

Please sign in to comment.