diff --git a/.gitignore b/.gitignore index 51a74d35cc..3f3d9e916a 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,5 @@ build /cmake-build-* dev -kphp +/kphp kphp_out diff --git a/runtime-light/allocator/allocator-state.cpp b/runtime-light/allocator/allocator-state.cpp deleted file mode 100644 index 88d8c1d43b..0000000000 --- a/runtime-light/allocator/allocator-state.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/allocator/allocator-state.h" - -#include "runtime-light/k2-platform/k2-api.h" -#include "runtime-light/state/component-state.h" -#include "runtime-light/state/image-state.h" -#include "runtime-light/state/instance-state.h" -#include "runtime-light/stdlib/diagnostics/logs.h" - -const AllocatorState& AllocatorState::get() noexcept { - if (const auto* instance_state_ptr{k2::instance_state()}; instance_state_ptr != nullptr) [[likely]] { - return instance_state_ptr->instance_allocator_state; - } else if (const auto* component_state_ptr{k2::component_state()}; component_state_ptr != nullptr) { - return component_state_ptr->component_allocator_state; - } else if (const auto* image_state_ptr{k2::image_state()}; image_state_ptr != nullptr) { - return image_state_ptr->image_allocator_state; - } - kphp::log::error("can't find allocator state"); -} - -AllocatorState& AllocatorState::get_mutable() noexcept { - return const_cast(AllocatorState::get()); -} diff --git a/runtime-light/allocator/allocator-state.h b/runtime-light/allocator/allocator-state.h index bf0f15d423..a5cc2e79e7 100644 --- a/runtime-light/allocator/allocator-state.h +++ b/runtime-light/allocator/allocator-state.h @@ -33,5 +33,7 @@ class AllocatorState final : private vk::not_copyable { : allocator(script_mem_size, min_extra_mem_size, oom_handling_mem_size) {} static const AllocatorState& get() noexcept; - static AllocatorState& get_mutable() noexcept; + static AllocatorState& get_mutable() noexcept { + return const_cast(get()); + } }; diff --git a/runtime-light/allocator/allocator.cmake b/runtime-light/allocator/allocator.cmake index 78a9747af4..85880d002e 100644 --- a/runtime-light/allocator/allocator.cmake +++ b/runtime-light/allocator/allocator.cmake @@ -1,2 +1 @@ -set(RUNTIME_LIGHT_ALLOCATOR_SRC allocator/allocator-state.cpp - allocator/runtime-light-allocator.cpp) +set(RUNTIME_LIGHT_ALLOCATOR_SRC allocator/runtime-light-allocator.cpp) diff --git a/runtime-light/components/confdata/bindings/bindings.cpp b/runtime-light/components/confdata/bindings/bindings.cpp new file mode 100644 index 0000000000..5d3ae4366a --- /dev/null +++ b/runtime-light/components/confdata/bindings/bindings.cpp @@ -0,0 +1,54 @@ +// Compiler for PHP (aka KPHP) +// Copyright (c) 2026 LLC «V Kontakte» +// Distributed under the GPL v3 License, see LICENSE.notice.txt + +#include +#include + +#include "runtime-common/core/runtime-core.h" +#include "runtime-light/allocator/allocator-state.h" +#include "runtime-light/components/confdata/state/instance-state.h" +#include "runtime-light/coroutine/coroutine-state.h" +#include "runtime-light/coroutine/io-scheduler.h" +#include "runtime-light/k2-platform/k2-api.h" +#include "runtime-light/stdlib/diagnostics/contextual-tags.h" +#include "runtime-light/stdlib/diagnostics/error-handling-state.h" +#include "runtime-light/stdlib/diagnostics/logs.h" + +namespace kphp::coro { + +auto instance_state::get() noexcept -> instance_state& { + return InstanceState::get().coroutine_instance_state; +} + +auto io_scheduler::get() noexcept -> io_scheduler& { + return InstanceState::get().io_scheduler; +} + +} // namespace kphp::coro + +namespace kphp::log { + +auto contextual_tags::try_get() noexcept -> std::optional> { + if (k2::instance_state() != nullptr) [[likely]] { + return InstanceState::get().instance_tags; + } + return std::nullopt; +} + +} // namespace kphp::log + +auto AllocatorState::get() noexcept -> const AllocatorState& { + if (k2::instance_state() != nullptr) [[likely]] { + return InstanceState::get().instance_allocator_state; + } + kphp::log::error("can't find allocator state"); +} + +auto ErrorHandlingState::try_get() noexcept -> std::optional> { + return std::nullopt; // confdata doesn't support PHP error handling +} + +auto RuntimeContext::get() noexcept -> RuntimeContext& { + kphp::log::error("unexpected access to RuntimeContext"); // confdata doesn't have a runtime context +} diff --git a/runtime-light/components/confdata/confdata-component.cpp b/runtime-light/components/confdata/confdata-component.cpp new file mode 100644 index 0000000000..d846ce020c --- /dev/null +++ b/runtime-light/components/confdata/confdata-component.cpp @@ -0,0 +1,82 @@ +// Compiler for PHP (aka KPHP) +// Copyright (c) 2026 LLC «V Kontakte» +// Distributed under the GPL v3 License, see LICENSE.notice.txt + +#include +#include + +#include "runtime-light/components/confdata/state/component-state.h" +#include "runtime-light/components/confdata/state/image-state.h" +#include "runtime-light/components/confdata/state/instance-state.h" +#include "runtime-light/coroutine/io-scheduler.h" +#include "runtime-light/k2-platform/k2-api.h" +#include "runtime-light/k2-platform/k2-header.h" +#include "runtime-light/stdlib/confdata/confdata-constants.h" + +#define VISIBILITY_DEFAULT __attribute__((visibility("default"))) + +VISIBILITY_DEFAULT ImageState* k2_create_image() { + k2::details::image_state_ptr = nullptr; + k2::details::component_state_ptr = nullptr; + k2::details::instance_state_ptr = nullptr; + return static_cast(k2::alloc_align(sizeof(ImageState), alignof(ImageState))); +} + +VISIBILITY_DEFAULT void k2_init_image() { + k2::details::image_state_ptr = k2_image_state(); + k2::details::component_state_ptr = nullptr; + k2::details::instance_state_ptr = nullptr; + new (const_cast(k2::image_state())) ImageState{}; +} + +VISIBILITY_DEFAULT ComponentState* k2_create_component() { + k2::details::image_state_ptr = k2_image_state(); + k2::details::component_state_ptr = nullptr; + k2::details::instance_state_ptr = nullptr; + return static_cast(k2::alloc_align(sizeof(ComponentState), alignof(ComponentState))); +} + +VISIBILITY_DEFAULT void k2_init_component() { + k2::details::image_state_ptr = k2_image_state(); + k2::details::component_state_ptr = k2_component_state(); + k2::details::instance_state_ptr = nullptr; + new (const_cast(k2::component_state())) ComponentState{}; +} + +VISIBILITY_DEFAULT InstanceState* k2_create_instance() { + k2::details::image_state_ptr = k2_image_state(); + k2::details::component_state_ptr = k2_component_state(); + k2::details::instance_state_ptr = nullptr; + return static_cast(k2::alloc_align(sizeof(InstanceState), alignof(InstanceState))); +} + +VISIBILITY_DEFAULT void k2_init_instance() { + k2::details::image_state_ptr = k2_image_state(); + k2::details::component_state_ptr = k2_component_state(); + k2::details::instance_state_ptr = k2_instance_state(); + new (k2::instance_state()) InstanceState{}; + k2::instance_state()->init(); +} + +VISIBILITY_DEFAULT k2::PollStatus k2_warmup() { + return k2::PollStatus::PollFinishedOk; +} + +VISIBILITY_DEFAULT k2::PollStatus k2_poll() { + k2::details::image_state_ptr = k2_image_state(); + k2::details::component_state_ptr = k2_component_state(); + k2::details::instance_state_ptr = k2_instance_state(); + return kphp::coro::io_scheduler::get().process_events(); +} + +VISIBILITY_DEFAULT const ImageInfo* k2_describe() { + static constexpr std::array extra_info{ImageInfo::KeyValuePair{.key = "compiler_version", .value = K2_CONFDATA_COMPILER_VERSION}}; + static constexpr ImageInfo image_info{.image_name = kphp::confdata::COMPONENT_NAME.data(), + .is_oneshot = 0, + .build_timestamp = K2_CONFDATA_BUILD_TIMESTAMP, + .header_h_version = K2_PLATFORM_HEADER_H_VERSION, + .version = "0.0.1", + .extra_info_size = extra_info.size(), + .extra_info = extra_info.data()}; + return std::addressof(image_info); +} diff --git a/runtime-light/components/confdata/confdata.cmake b/runtime-light/components/confdata/confdata.cmake new file mode 100644 index 0000000000..a6f2478d31 --- /dev/null +++ b/runtime-light/components/confdata/confdata.cmake @@ -0,0 +1,44 @@ +# k2-confdata image: a standalone C++ component that shares the common +# runtime-light machinery but provides its own entry points and bindings +set(K2_CONFDATA_COMPONENT_SRC + ${RUNTIME_LIGHT_DIR}/components/confdata/confdata-component.cpp + ${RUNTIME_LIGHT_DIR}/components/confdata/bindings/bindings.cpp + ${RUNTIME_LIGHT_DIR}/components/confdata/state/instance-state.cpp) + +set(K2_CONFDATA_ALLOCATOR_SRC + ${RUNTIME_LIGHT_DIR}/allocator/runtime-light-allocator.cpp + ${RUNTIME_LIGHT_DIR}/memory-resource-impl/monotonic-light-buffer-resource.cpp) + +set(K2_CONFDATA_DIAGNOSTICS_SRC + ${RUNTIME_LIGHT_DIR}/stdlib/diagnostics/backtrace.cpp + ${RUNTIME_LIGHT_DIR}/stdlib/diagnostics/php-assert.cpp) + +set(K2_CONFDATA_MEMORY_RESOURCE_SRC + ${RUNTIME_COMMON_DIR}/core/memory-resource/unsynchronized_pool_resource.cpp + ${RUNTIME_COMMON_DIR}/core/memory-resource/monotonic_buffer_resource.cpp + ${RUNTIME_COMMON_DIR}/core/memory-resource/details/memory_chunk_tree.cpp + ${RUNTIME_COMMON_DIR}/core/memory-resource/details/memory_ordered_chunk_list.cpp) + +set(K2_CONFDATA_SRC + ${K2_CONFDATA_COMPONENT_SRC} + ${K2_CONFDATA_ALLOCATOR_SRC} + ${K2_CONFDATA_DIAGNOSTICS_SRC} + ${K2_CONFDATA_MEMORY_RESOURCE_SRC} + # link the alloc-wrapper objects directly (not as an archive) so that + # __wrap_* definitions are always present regardless of link order + $) + +vk_add_library_pic(k2-confdata-pic SHARED ${K2_CONFDATA_SRC}) +set_target_properties(k2-confdata-pic PROPERTIES PREFIX "" OUTPUT_NAME "k2-confdata" LIBRARY_OUTPUT_DIRECTORY ${OBJS_DIR}) +target_compile_options(k2-confdata-pic PUBLIC ${RUNTIME_LIGHT_COMPILE_FLAGS}) +# reuse the common link flags; cmake drives the link through the compiler, +# so bare ld options need the -Wl, prefix +set(K2_CONFDATA_LINK_FLAGS ${RUNTIME_LIGHT_LINK_FLAGS}) +if(NOT APPLE) + list(TRANSFORM K2_CONFDATA_LINK_FLAGS REPLACE "^--" "-Wl,--") +endif() +target_link_options(k2-confdata-pic PUBLIC ${K2_CONFDATA_LINK_FLAGS}) + +string(TIMESTAMP K2_CONFDATA_BUILD_TIMESTAMP "%s" UTC) +target_compile_definitions(k2-confdata-pic PRIVATE K2_CONFDATA_BUILD_TIMESTAMP=${K2_CONFDATA_BUILD_TIMESTAMP}ULL + K2_CONFDATA_COMPILER_VERSION="${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}") diff --git a/runtime-light/components/confdata/state/component-state.h b/runtime-light/components/confdata/state/component-state.h new file mode 100644 index 0000000000..c5e3059aa6 --- /dev/null +++ b/runtime-light/components/confdata/state/component-state.h @@ -0,0 +1,24 @@ +// Compiler for PHP (aka KPHP) +// Copyright (c) 2026 LLC «V Kontakte» +// Distributed under the GPL v3 License, see LICENSE.notice.txt + +#pragma once + +#include + +#include "common/mixin/not_copyable.h" +#include "runtime-light/k2-platform/k2-api.h" + +struct ComponentState final : private vk::not_copyable { + ComponentState() noexcept = default; + static auto get() noexcept -> const ComponentState&; + static auto get_mutable() noexcept -> ComponentState&; +}; + +inline auto ComponentState::get() noexcept -> const ComponentState& { + return *k2::component_state(); +} + +inline auto ComponentState::get_mutable() noexcept -> ComponentState& { + return const_cast(ComponentState::get()); +} diff --git a/runtime-light/components/confdata/state/image-state.h b/runtime-light/components/confdata/state/image-state.h new file mode 100644 index 0000000000..333d031425 --- /dev/null +++ b/runtime-light/components/confdata/state/image-state.h @@ -0,0 +1,24 @@ +// Compiler for PHP (aka KPHP) +// Copyright (c) 2026 LLC «V Kontakte» +// Distributed under the GPL v3 License, see LICENSE.notice.txt + +#pragma once + +#include + +#include "common/mixin/not_copyable.h" +#include "runtime-light/k2-platform/k2-api.h" + +struct ImageState final : private vk::not_copyable { + ImageState() noexcept = default; + static auto get() noexcept -> const ImageState&; + static auto get_mutable() noexcept -> ImageState&; +}; + +inline auto ImageState::get() noexcept -> const ImageState& { + return *k2::image_state(); +} + +inline auto ImageState::get_mutable() noexcept -> ImageState& { + return const_cast(ImageState::get()); +} diff --git a/runtime-light/components/confdata/state/instance-state.cpp b/runtime-light/components/confdata/state/instance-state.cpp new file mode 100644 index 0000000000..1aaa3c42f4 --- /dev/null +++ b/runtime-light/components/confdata/state/instance-state.cpp @@ -0,0 +1,39 @@ +// Compiler for PHP (aka KPHP) +// Copyright (c) 2026 LLC «V Kontakte» +// Distributed under the GPL v3 License, see LICENSE.notice.txt + +#include "runtime-light/components/confdata/state/instance-state.h" + +#include +#include +#include +#include + +#include "runtime-light/coroutine/task.h" +#include "runtime-light/stdlib/diagnostics/logs.h" +#include "runtime-light/streams/stream.h" + +auto InstanceState::init() noexcept -> void { + auto main_task{run()}; + // initialize async stack + auto& main_task_async_stack_frame{main_task.get_handle().promise().get_async_stack_frame()}; + main_task_async_stack_frame.async_stack_root = std::addressof(coroutine_instance_state.coroutine_stack_root); + coroutine_instance_state.coroutine_stack_root.top_async_stack_frame = std::addressof(main_task_async_stack_frame); + // spawn main task onto the scheduler + kphp::log::assertion(io_scheduler.spawn(std::move(main_task))); +} + +auto InstanceState::run() noexcept -> kphp::coro::task<> { + auto opt_stream{co_await kphp::component::stream::accept()}; + if (!opt_stream.has_value()) [[unlikely]] { + kphp::log::warning("failed to accept a stream"); + co_return; + } + auto request_stream{std::move(*opt_stream)}; + kphp::log::info("accepted a stream: descriptor -> {}", request_stream.descriptor()); + + // dummy implementation: drain the request and close + if (auto expected{co_await request_stream.read_all([](std::span) noexcept {})}; !expected) [[unlikely]] { + kphp::log::warning("failed to read a request: error -> {}", expected.error()); + } +} diff --git a/runtime-light/components/confdata/state/instance-state.h b/runtime-light/components/confdata/state/instance-state.h new file mode 100644 index 0000000000..4a7243baea --- /dev/null +++ b/runtime-light/components/confdata/state/instance-state.h @@ -0,0 +1,38 @@ +// Compiler for PHP (aka KPHP) +// Copyright (c) 2026 LLC «V Kontakte» +// Distributed under the GPL v3 License, see LICENSE.notice.txt + +#pragma once + +#include + +#include "common/mixin/not_copyable.h" +#include "runtime-light/allocator/allocator-state.h" +#include "runtime-light/coroutine/coroutine-state.h" +#include "runtime-light/coroutine/io-scheduler.h" +#include "runtime-light/coroutine/task.h" +#include "runtime-light/k2-platform/k2-api.h" +#include "runtime-light/stdlib/diagnostics/contextual-tags.h" + +struct InstanceState final : vk::not_copyable { + AllocatorState instance_allocator_state{INIT_INSTANCE_ALLOCATOR_SIZE, DEFAULT_MIN_EXTRA_MEMORY_POOL_SIZE, 0}; + + kphp::log::contextual_tags instance_tags; + + kphp::coro::instance_state coroutine_instance_state; + kphp::coro::io_scheduler io_scheduler{coroutine_instance_state}; + + InstanceState() noexcept = default; + static auto get() noexcept -> InstanceState&; + + auto init() noexcept -> void; + +private: + static constexpr auto INIT_INSTANCE_ALLOCATOR_SIZE = static_cast(16U * 1024U * 1024U); // 16MiB + + auto run() noexcept -> kphp::coro::task<>; +}; + +inline auto InstanceState::get() noexcept -> InstanceState& { + return *k2::instance_state(); +} diff --git a/runtime-light/components/kphp/bindings/bindings.cpp b/runtime-light/components/kphp/bindings/bindings.cpp new file mode 100644 index 0000000000..5f1b40b704 --- /dev/null +++ b/runtime-light/components/kphp/bindings/bindings.cpp @@ -0,0 +1,253 @@ +// Compiler for PHP (aka KPHP) +// Copyright (c) 2026 LLC «V Kontakte» +// Distributed under the GPL v3 License, see LICENSE.notice.txt + +#include +#include +#include + +#include "runtime-common/core/runtime-core.h" +#include "runtime-light/allocator/allocator-state.h" +#include "runtime-light/components/kphp/state/component-state.h" +#include "runtime-light/components/kphp/state/image-state.h" +#include "runtime-light/components/kphp/state/instance-state.h" +#include "runtime-light/core/globals/php-script-globals.h" +#include "runtime-light/coroutine/coroutine-state.h" +#include "runtime-light/coroutine/io-scheduler.h" +#include "runtime-light/k2-platform/k2-api.h" +#include "runtime-light/server/cli/cli-instance-state.h" +#include "runtime-light/server/http/http-server-state.h" +#include "runtime-light/server/job-worker/job-worker-server-state.h" +#include "runtime-light/server/rpc/rpc-server-state.h" +#include "runtime-light/stdlib/confdata/confdata-state.h" +#include "runtime-light/stdlib/curl/curl-state.h" +#include "runtime-light/stdlib/diagnostics/contextual-tags.h" +#include "runtime-light/stdlib/diagnostics/error-handling-state.h" +#include "runtime-light/stdlib/diagnostics/logs.h" +#include "runtime-light/stdlib/file/file-system-state.h" +#include "runtime-light/stdlib/fork/fork-state.h" +#include "runtime-light/stdlib/fork/wait-queue-state.h" +#include "runtime-light/stdlib/instance-cache/instance-cache-state.h" +#include "runtime-light/stdlib/job-worker/job-worker-client-state.h" +#include "runtime-light/stdlib/kml/kml-state.h" +#include "runtime-light/stdlib/math/math-state.h" +#include "runtime-light/stdlib/math/random-state.h" +#include "runtime-light/stdlib/output/output-state.h" +#include "runtime-light/stdlib/rpc/rpc-client-state.h" +#include "runtime-light/stdlib/rpc/rpc-queue-state.h" +#include "runtime-light/stdlib/serialization/serialization-state.h" +#include "runtime-light/stdlib/string/regex-state.h" +#include "runtime-light/stdlib/string/string-state.h" +#include "runtime-light/stdlib/system/system-state.h" +#include "runtime-light/stdlib/time/time-state.h" +#include "runtime-light/stdlib/web-transfer-lib/web-state.h" + +namespace kphp::coro { + +auto instance_state::get() noexcept -> instance_state& { + return InstanceState::get().coroutine_instance_state; +} + +auto io_scheduler::get() noexcept -> io_scheduler& { + return InstanceState::get().io_scheduler; +} + +} // namespace kphp::coro + +namespace kphp::log { + +auto contextual_tags::try_get() noexcept -> std::optional> { + if (auto* instance_state_ptr{k2::instance_state()}; instance_state_ptr != nullptr) [[likely]] { + return instance_state_ptr->instance_tags; + } + return std::nullopt; +} + +} // namespace kphp::log + +auto AllocatorState::get() noexcept -> const AllocatorState& { + if (const auto* instance_state_ptr{k2::instance_state()}; instance_state_ptr != nullptr) [[likely]] { + return instance_state_ptr->instance_allocator_state; + } else if (const auto* component_state_ptr{k2::component_state()}; component_state_ptr != nullptr) { + return component_state_ptr->component_allocator_state; + } else if (const auto* image_state_ptr{k2::image_state()}; image_state_ptr != nullptr) { + return image_state_ptr->image_allocator_state; + } + kphp::log::error("can't find allocator state"); +} + +auto RuntimeContext::get() noexcept -> RuntimeContext& { + if (auto* instance_state_ptr{k2::instance_state()}; instance_state_ptr != nullptr) [[likely]] { + return instance_state_ptr->runtime_context; + } + kphp::log::error("unexpected access to RuntimeContext"); +} + +auto PhpScriptMutableGlobals::current() noexcept -> PhpScriptMutableGlobals& { + return InstanceState::get().php_script_mutable_globals_singleton; +} + +ErrorHandlingState::ErrorHandlingState() noexcept { + const auto& component_st{ComponentState::get()}; + const auto& default_level_str{component_st.ini_opts.get_value(string{INI_ERROR_REPORTING_KEY.data(), INI_ERROR_REPORTING_KEY.size()})}; + if (default_level_str.empty() || !default_level_str.is_int()) { + return; + } + + const int64_t default_level{default_level_str.to_int()}; + minimum_log_level = static_cast(SUPPORTED_ERROR_LEVELS & default_level) ? default_level : minimum_log_level; +} + +auto ErrorHandlingState::get() noexcept -> ErrorHandlingState& { + return InstanceState::get().error_handling_instance_state; +} + +auto ErrorHandlingState::try_get() noexcept -> std::optional> { + if (auto* instance_state_ptr{k2::instance_state()}; instance_state_ptr != nullptr) [[likely]] { + return instance_state_ptr->error_handling_instance_state; + } + return std::nullopt; +} + +auto CLIInstanceInstance::get() noexcept -> CLIInstanceInstance& { + return InstanceState::get().cli_instance_instate; +} + +auto HttpServerInstanceState::get() noexcept -> HttpServerInstanceState& { + return InstanceState::get().http_server_instance_state; +} + +auto JobWorkerServerInstanceState::get() noexcept -> JobWorkerServerInstanceState& { + return InstanceState::get().job_worker_server_instance_state; +} + +auto RpcServerInstanceState::get() noexcept -> RpcServerInstanceState& { + return InstanceState::get().rpc_server_instance_state; +} + +auto ConfdataInstanceState::get() noexcept -> ConfdataInstanceState& { + return InstanceState::get().confdata_instance_state; +} + +auto CurlInstanceState::get() noexcept -> CurlInstanceState& { + return InstanceState::get().curl_instance_state; +} + +auto CurlImageState::get() noexcept -> const CurlImageState& { + return ImageState::get().curl_image_state; +} + +auto FileSystemImageState::get() noexcept -> const FileSystemImageState& { + return ImageState::get().file_system_image_state; +} + +auto ForkInstanceState::get() noexcept -> ForkInstanceState& { + return InstanceState::get().fork_instance_state; +} + +auto InstanceCacheInstanceState::get() noexcept -> InstanceCacheInstanceState& { + return InstanceState::get().instance_cache_instance_state; +} + +auto JobWorkerClientInstanceState::get() noexcept -> JobWorkerClientInstanceState& { + return InstanceState::get().job_worker_client_instance_state; +} + +template<> +auto KmlComponentState::get() noexcept -> const KmlComponentState& { + return ComponentState::get().kml_component_state; +} + +template<> +auto KmlComponentState::get_mutable() noexcept -> KmlComponentState& { + return const_cast(KmlComponentState::get()); +} + +template<> +auto KmlInstanceState::get() noexcept -> KmlInstanceState& { + return InstanceState::get().kml_instance_state; +} + +auto MathInstanceState::get() noexcept -> MathInstanceState& { + return InstanceState::get().math_instance_state; +} + +auto MathImageState::get() noexcept -> const MathImageState& { + return ImageState::get().math_image_state; +} + +auto OutputInstanceState::get() noexcept -> OutputInstanceState& { + return InstanceState::get().output_instance_state; +} + +auto RandomInstanceState::get() noexcept -> RandomInstanceState& { + return InstanceState::get().random_instance_state; +} + +auto RegexInstanceState::get() noexcept -> RegexInstanceState& { + return InstanceState::get().regex_instance_state; +} + +auto RegexImageState::get() noexcept -> const RegexImageState& { + return ImageState::get().regex_image_state; +} + +auto RegexImageState::get_mutable() noexcept -> RegexImageState& { + return ImageState::get_mutable().regex_image_state; +} + +auto RpcClientInstanceState::get() noexcept -> RpcClientInstanceState& { + return InstanceState::get().rpc_client_instance_state; +} + +auto RpcImageState::get() noexcept -> const RpcImageState& { + return ImageState::get().rpc_image_state; +} + +auto RpcImageState::get_mutable() noexcept -> RpcImageState& { + return ImageState::get_mutable().rpc_image_state; +} + +auto RpcQueueInstanceState::get() noexcept -> RpcQueueInstanceState& { + return InstanceState::get().rpc_queue_instance_state; +} + +auto SerializationInstanceState::get() noexcept -> SerializationInstanceState& { + return InstanceState::get().serialization_instance_state; +} + +auto SerializationImageState::get() noexcept -> const SerializationImageState& { + return ImageState::get().serialization_image_state; +} + +auto StringInstanceState::get() noexcept -> StringInstanceState& { + return InstanceState::get().string_instance_state; +} + +auto StringImageState::get() noexcept -> const StringImageState& { + return ImageState::get().string_image_state; +} + +auto SystemInstanceState::get() noexcept -> SystemInstanceState& { + return InstanceState::get().system_instance_state; +} + +auto TimeInstanceState::get() noexcept -> TimeInstanceState& { + return InstanceState::get().time_instance_state; +} + +auto TimeImageState::get() noexcept -> const TimeImageState& { + return ImageState::get().time_image_state; +} + +auto TimeImageState::get_mutable() noexcept -> TimeImageState& { + return ImageState::get_mutable().time_image_state; +} + +auto WaitQueueInstanceState::get() noexcept -> WaitQueueInstanceState& { + return InstanceState::get().wait_queue_instance_state; +} + +auto WebInstanceState::get() noexcept -> WebInstanceState& { + return InstanceState::get().web_instance_state; +} diff --git a/runtime-light/runtime-light.cpp b/runtime-light/components/kphp/kphp-component.cpp similarity index 66% rename from runtime-light/runtime-light.cpp rename to runtime-light/components/kphp/kphp-component.cpp index 3afbcb8332..c10c005230 100644 --- a/runtime-light/runtime-light.cpp +++ b/runtime-light/components/kphp/kphp-component.cpp @@ -4,13 +4,13 @@ #include +#include "runtime-light/components/kphp/state/component-state.h" +#include "runtime-light/components/kphp/state/image-state.h" +#include "runtime-light/components/kphp/state/instance-state.h" #include "runtime-light/core/globals/php-init-scripts.h" #include "runtime-light/coroutine/io-scheduler.h" #include "runtime-light/k2-platform/k2-api.h" #include "runtime-light/k2-platform/k2-header.h" -#include "runtime-light/state/component-state.h" -#include "runtime-light/state/image-state.h" -#include "runtime-light/state/instance-state.h" #include "runtime-light/stdlib/diagnostics/logs.h" #define VISIBILITY_DEFAULT __attribute__((visibility("default"))) @@ -34,54 +34,41 @@ VISIBILITY_DEFAULT ComponentState* k2_create_component() { k2::details::image_state_ptr = k2_image_state(); k2::details::component_state_ptr = nullptr; k2::details::instance_state_ptr = nullptr; - kphp::log::debug("start component state creation, requested {} bytes", sizeof(ComponentState)); - auto* component_state_ptr{static_cast(k2::alloc_align(sizeof(ComponentState), alignof(ComponentState)))}; - kphp::log::debug("finish component state creation"); - return component_state_ptr; + return static_cast(k2::alloc_align(sizeof(ComponentState), alignof(ComponentState))); } VISIBILITY_DEFAULT void k2_init_component() { k2::details::image_state_ptr = k2_image_state(); k2::details::component_state_ptr = k2_component_state(); k2::details::instance_state_ptr = nullptr; - kphp::log::debug("start component state init"); new (const_cast(k2::component_state())) ComponentState{}; - kphp::log::debug("finish component state init"); } VISIBILITY_DEFAULT InstanceState* k2_create_instance() { k2::details::image_state_ptr = k2_image_state(); k2::details::component_state_ptr = k2_component_state(); k2::details::instance_state_ptr = nullptr; - kphp::log::debug("start instance state creation, requested {} bytes", sizeof(InstanceState)); - auto* instance_state_ptr{static_cast(k2::alloc_align(sizeof(InstanceState), alignof(InstanceState)))}; - kphp::log::debug("finish instance state creation"); - return instance_state_ptr; + return static_cast(k2::alloc_align(sizeof(InstanceState), alignof(InstanceState))); } VISIBILITY_DEFAULT void k2_init_instance() { k2::details::image_state_ptr = k2_image_state(); k2::details::component_state_ptr = k2_component_state(); k2::details::instance_state_ptr = k2_instance_state(); - kphp::log::debug("start instance state init"); new (k2::instance_state()) InstanceState{}; k2::instance_state()->init_script_execution(); - kphp::log::debug("finish instance state init"); } VISIBILITY_DEFAULT k2::PollStatus k2_warmup() { - kphp::log::debug("start instance warmup"); - const auto warmup_status{k2::PollStatus::PollFinishedOk}; - kphp::log::debug("finish instance warmup"); - return warmup_status; + return k2::PollStatus::PollFinishedOk; } VISIBILITY_DEFAULT k2::PollStatus k2_poll() { k2::details::image_state_ptr = k2_image_state(); k2::details::component_state_ptr = k2_component_state(); k2::details::instance_state_ptr = k2_instance_state(); - kphp::log::debug("k2_poll started"); + kphp::log::trace("k2_poll started"); const auto poll_status{kphp::coro::io_scheduler::get().process_events()}; - kphp::log::debug("k2_poll finished: {}", std::to_underlying(poll_status)); + kphp::log::trace("k2_poll finished: {}", std::to_underlying(poll_status)); return poll_status; } diff --git a/runtime-light/components/kphp/kphp.cmake b/runtime-light/components/kphp/kphp.cmake new file mode 100644 index 0000000000..3e786ff62e --- /dev/null +++ b/runtime-light/components/kphp/kphp.cmake @@ -0,0 +1,3 @@ +prepend(RUNTIME_LIGHT_KPHP_COMPONENT_SRC components/kphp/ kphp-component.cpp + bindings/bindings.cpp state/component-state.cpp + state/instance-state.cpp) diff --git a/runtime-light/state/component-state.cpp b/runtime-light/components/kphp/state/component-state.cpp similarity index 98% rename from runtime-light/state/component-state.cpp rename to runtime-light/components/kphp/state/component-state.cpp index 5463088f88..9cd5b6e9da 100644 --- a/runtime-light/state/component-state.cpp +++ b/runtime-light/components/kphp/state/component-state.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2024 LLC «V Kontakte» // Distributed under the GPL v3 License, see LICENSE.notice.txt -#include "runtime-light/state/component-state.h" +#include "runtime-light/components/kphp/state/component-state.h" #include #include diff --git a/runtime-light/state/component-state.h b/runtime-light/components/kphp/state/component-state.h similarity index 100% rename from runtime-light/state/component-state.h rename to runtime-light/components/kphp/state/component-state.h diff --git a/runtime-light/state/image-state.h b/runtime-light/components/kphp/state/image-state.h similarity index 100% rename from runtime-light/state/image-state.h rename to runtime-light/components/kphp/state/image-state.h diff --git a/runtime-light/state/instance-state.cpp b/runtime-light/components/kphp/state/instance-state.cpp similarity index 98% rename from runtime-light/state/instance-state.cpp rename to runtime-light/components/kphp/state/instance-state.cpp index 4bb90f6e55..e544ef9cb3 100644 --- a/runtime-light/state/instance-state.cpp +++ b/runtime-light/components/kphp/state/instance-state.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2024 LLC «V Kontakte» // Distributed under the GPL v3 License, see LICENSE.notice.txt -#include "runtime-light/state/instance-state.h" +#include "runtime-light/components/kphp/state/instance-state.h" #include #include @@ -15,6 +15,7 @@ #include "runtime-common/core/allocator/script-allocator.h" #include "runtime-common/core/runtime-core.h" #include "runtime-common/core/std/containers.h" +#include "runtime-light/components/kphp/state/component-state.h" #include "runtime-light/core/globals/php-init-scripts.h" #include "runtime-light/core/globals/php-script-globals.h" #include "runtime-light/coroutine/await-set.h" @@ -24,7 +25,6 @@ #include "runtime-light/server/http/http-server-state.h" #include "runtime-light/server/http/init-functions.h" #include "runtime-light/server/rpc/init-functions.h" -#include "runtime-light/state/component-state.h" #include "runtime-light/stdlib/component/component-api.h" #include "runtime-light/stdlib/diagnostics/logs.h" #include "runtime-light/stdlib/fork/fork-functions.h" diff --git a/runtime-light/state/instance-state.h b/runtime-light/components/kphp/state/instance-state.h similarity index 96% rename from runtime-light/state/instance-state.h rename to runtime-light/components/kphp/state/instance-state.h index f48a39f9c8..65ba170383 100644 --- a/runtime-light/state/instance-state.h +++ b/runtime-light/components/kphp/state/instance-state.h @@ -11,6 +11,7 @@ #include "runtime-common/core/runtime-core.h" #include "runtime-common/core/std/containers.h" #include "runtime-light/allocator/allocator-state.h" +#include "runtime-light/components/kphp/state/component-state.h" #include "runtime-light/core/globals/php-script-globals.h" #include "runtime-light/coroutine/coroutine-state.h" #include "runtime-light/coroutine/io-scheduler.h" @@ -20,7 +21,6 @@ #include "runtime-light/server/http/http-server-state.h" #include "runtime-light/server/job-worker/job-worker-server-state.h" #include "runtime-light/server/rpc/rpc-server-state.h" -#include "runtime-light/state/component-state.h" #include "runtime-light/stdlib/confdata/confdata-state.h" #include "runtime-light/stdlib/curl/curl-state.h" #include "runtime-light/stdlib/diagnostics/contextual-tags.h" @@ -91,9 +91,9 @@ struct InstanceState final : vk::not_copyable { AllocatorState instance_allocator_state{ComponentState::get().initial_instance_memory_size, ComponentState::get().min_instance_extra_memory_size, 0}; kphp::log::contextual_tags instance_tags; - kphp::coro::io_scheduler io_scheduler; - CoroutineInstanceState coroutine_instance_state; + kphp::coro::instance_state coroutine_instance_state; + kphp::coro::io_scheduler io_scheduler{coroutine_instance_state}; ForkInstanceState fork_instance_state; WaitQueueInstanceState wait_queue_instance_state; RpcQueueInstanceState rpc_queue_instance_state; diff --git a/runtime-light/core/globals/php-script-globals.cpp b/runtime-light/core/globals/php-script-globals.cpp index 98ca963a4b..298b304de9 100644 --- a/runtime-light/core/globals/php-script-globals.cpp +++ b/runtime-light/core/globals/php-script-globals.cpp @@ -4,13 +4,10 @@ #include "php-script-globals.h" -#include "runtime-light/state/instance-state.h" +#include "common/php-functions.h" +#include "runtime-common/core/allocator/runtime-allocator.h" #include "runtime-light/stdlib/diagnostics/logs.h" -PhpScriptMutableGlobals& PhpScriptMutableGlobals::current() noexcept { - return InstanceState::get().php_script_mutable_globals_singleton; -} - void PhpScriptMutableGlobals::once_alloc_linear_mem(unsigned int n_bytes) { kphp::log::assertion(g_linear_mem == nullptr); g_linear_mem = static_cast(RuntimeAllocator::get().alloc0_global_memory(n_bytes)); diff --git a/runtime-light/core/kphp-core-impl/kphp-core-context.cpp b/runtime-light/core/kphp-core-impl/kphp-core-context.cpp index ce79f0ee45..4be268c33d 100644 --- a/runtime-light/core/kphp-core-impl/kphp-core-context.cpp +++ b/runtime-light/core/kphp-core-impl/kphp-core-context.cpp @@ -3,9 +3,6 @@ // Distributed under the GPL v3 License, see LICENSE.notice.txt #include "runtime-common/core/runtime-core.h" -#include "runtime-light/k2-platform/k2-api.h" -#include "runtime-light/state/instance-state.h" -#include "runtime-light/stdlib/diagnostics/logs.h" namespace { @@ -14,13 +11,6 @@ constexpr string_size_type initial_maximum_string_buffer_length = (1 << 24); } // namespace -RuntimeContext& RuntimeContext::get() noexcept { - if (auto* instance_state_ptr{k2::instance_state()}; instance_state_ptr != nullptr) [[likely]] { - return instance_state_ptr->runtime_context; - } - kphp::log::error("unexpected access to RuntimeContext"); -} - void RuntimeContext::init() noexcept { init_string_buffer_lib(initial_minimum_string_buffer_length, initial_maximum_string_buffer_length); } diff --git a/runtime-light/coroutine/await-set.h b/runtime-light/coroutine/await-set.h index 1fbf78de2e..3117d46cc7 100644 --- a/runtime-light/coroutine/await-set.h +++ b/runtime-light/coroutine/await-set.h @@ -26,7 +26,7 @@ class await_set { public: await_set() noexcept : m_await_broker(std::make_unique>()), - m_coroutine_stack_root(CoroutineInstanceState::get().coroutine_stack_root) {} + m_coroutine_stack_root(kphp::coro::instance_state::get().coroutine_stack_root) {} await_set(await_set&& other) noexcept : m_await_broker(std::move(other.m_await_broker)), @@ -40,6 +40,8 @@ class await_set { return *this; } + ~await_set() noexcept = default; + await_set(const await_set&) = delete; await_set& operator=(const await_set&) = delete; diff --git a/runtime-light/coroutine/coroutine-state.cpp b/runtime-light/coroutine/coroutine-state.cpp deleted file mode 100644 index b7dc08d01d..0000000000 --- a/runtime-light/coroutine/coroutine-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/coroutine/coroutine-state.h" - -#include "runtime-light/state/instance-state.h" - -CoroutineInstanceState& CoroutineInstanceState::get() noexcept { - return InstanceState::get().coroutine_instance_state; -} diff --git a/runtime-light/coroutine/coroutine-state.h b/runtime-light/coroutine/coroutine-state.h index b6d260c278..169ff00993 100644 --- a/runtime-light/coroutine/coroutine-state.h +++ b/runtime-light/coroutine/coroutine-state.h @@ -8,11 +8,15 @@ #include "runtime-light/coroutine/async-stack.h" -struct CoroutineInstanceState final : private vk::not_copyable { +namespace kphp::coro { - CoroutineInstanceState() noexcept = default; +struct instance_state final : private vk::not_copyable { - static CoroutineInstanceState& get() noexcept; + instance_state() noexcept = default; + + static instance_state& get() noexcept; kphp::coro::async_stack_root coroutine_stack_root; }; + +} // namespace kphp::coro diff --git a/runtime-light/coroutine/coroutine.cmake b/runtime-light/coroutine/coroutine.cmake deleted file mode 100644 index 83fc6e2858..0000000000 --- a/runtime-light/coroutine/coroutine.cmake +++ /dev/null @@ -1,2 +0,0 @@ -prepend(RUNTIME_LIGHT_COROUTINE_SRC coroutine/ coroutine-state.cpp - io-scheduler.cpp) diff --git a/runtime-light/coroutine/detail/task-self-deleting.h b/runtime-light/coroutine/detail/task-self-deleting.h index 73dcc51e59..e6908f575b 100644 --- a/runtime-light/coroutine/detail/task-self-deleting.h +++ b/runtime-light/coroutine/detail/task-self-deleting.h @@ -77,7 +77,7 @@ class task_self_deleting { // initialize task_self_deleting's frame as top async stack frame auto& async_stack_frame{m_promise.get_async_stack_frame()}; async_stack_frame.return_address = STACK_RETURN_ADDRESS; - async_stack_frame.async_stack_root = std::addressof(CoroutineInstanceState::get().coroutine_stack_root); + async_stack_frame.async_stack_root = std::addressof(kphp::coro::instance_state::get().coroutine_stack_root); } ~task_self_deleting() noexcept = default; diff --git a/runtime-light/coroutine/event.h b/runtime-light/coroutine/event.h index 905345c97a..4be3984ac8 100644 --- a/runtime-light/coroutine/event.h +++ b/runtime-light/coroutine/event.h @@ -41,7 +41,7 @@ class event { explicit awaiter(event_controller& event_controller) noexcept : m_controller(event_controller), - m_async_stack_root(CoroutineInstanceState::get().coroutine_stack_root) {} + m_async_stack_root(kphp::coro::instance_state::get().coroutine_stack_root) {} awaiter(const awaiter&) = delete; awaiter(awaiter&&) = delete; diff --git a/runtime-light/coroutine/io-scheduler.cpp b/runtime-light/coroutine/io-scheduler.cpp deleted file mode 100644 index ea22b37b76..0000000000 --- a/runtime-light/coroutine/io-scheduler.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/coroutine/io-scheduler.h" - -#include "runtime-light/state/instance-state.h" - -namespace kphp::coro { - -io_scheduler& io_scheduler::get() noexcept { - return InstanceState::get().io_scheduler; -} - -} // namespace kphp::coro diff --git a/runtime-light/coroutine/io-scheduler.h b/runtime-light/coroutine/io-scheduler.h index 406016184e..781173699f 100644 --- a/runtime-light/coroutine/io-scheduler.h +++ b/runtime-light/coroutine/io-scheduler.h @@ -54,7 +54,7 @@ class io_scheduler { kphp::coro::detail::poll_info::parked_polls m_parked_polls; kphp::coro::detail::poll_info::scheduled_coroutines m_scheduled_coroutines; - CoroutineInstanceState& m_coroutine_instance_state{CoroutineInstanceState::get()}; + kphp::coro::instance_state& m_coro_instance_state; auto make_cancellation_handler(kphp::coro::detail::poll_info& poll_info) noexcept; auto make_timeout_task(std::chrono::milliseconds timeout) noexcept -> kphp::coro::task; @@ -69,7 +69,8 @@ class io_scheduler { auto remove_timer_token(kphp::coro::detail::poll_info::timed_events::iterator pos) noexcept -> void; public: - io_scheduler() noexcept = default; + explicit io_scheduler(kphp::coro::instance_state& coroutine_instance_state) noexcept + : m_coro_instance_state(coroutine_instance_state) {} ~io_scheduler() = default; io_scheduler(const io_scheduler&) = delete; @@ -427,7 +428,7 @@ inline auto io_scheduler::process_events() noexcept -> k2::PollStatus { */ scheduled_coroutines.pop_front(); kphp::log::assertion(static_cast(coroutine)); - kphp::coro::resume(coroutine, m_coroutine_instance_state.coroutine_stack_root); + kphp::coro::resume(coroutine, m_coro_instance_state.coroutine_stack_root); } } @@ -452,7 +453,7 @@ auto io_scheduler::start(coroutine_type coroutine) noexcept -> bool { if (!handle || handle.done()) [[unlikely]] { return false; } - kphp::coro::resume(handle, m_coroutine_instance_state.coroutine_stack_root); + kphp::coro::resume(handle, m_coro_instance_state.coroutine_stack_root); return true; } @@ -466,7 +467,7 @@ inline auto io_scheduler::schedule() noexcept { explicit schedule_operation(io_scheduler& scheduler) noexcept : m_scheduler(scheduler), - m_async_stack_frame(m_scheduler.m_coroutine_instance_state.coroutine_stack_root.top_async_stack_frame) {} + m_async_stack_frame(m_scheduler.m_coro_instance_state.coroutine_stack_root.top_async_stack_frame) {} public: schedule_operation(const schedule_operation&) = delete; @@ -508,7 +509,7 @@ inline auto io_scheduler::schedule() noexcept { auto await_resume() noexcept -> void { m_schedule_pos = std::monostate{}; - m_scheduler.m_coroutine_instance_state.coroutine_stack_root.top_async_stack_frame = m_async_stack_frame; + m_scheduler.m_coro_instance_state.coroutine_stack_root.top_async_stack_frame = m_async_stack_frame; } }; return schedule_operation{*this}; diff --git a/runtime-light/runtime-light.cmake b/runtime-light/runtime-light.cmake index e5df2f323d..a0fe34d878 100644 --- a/runtime-light/runtime-light.cmake +++ b/runtime-light/runtime-light.cmake @@ -16,28 +16,24 @@ set(RUNTIME_LIGHT_LINK_FLAGS -stdlib=libc++ -static-libstdc++ -static-libgcc ${R # ================================================================================================= include(${RUNTIME_LIGHT_DIR}/allocator/allocator.cmake) +include(${RUNTIME_LIGHT_DIR}/components/kphp/kphp.cmake) include(${RUNTIME_LIGHT_DIR}/core/core.cmake) -include(${RUNTIME_LIGHT_DIR}/coroutine/coroutine.cmake) include(${RUNTIME_LIGHT_DIR}/server/server.cmake) include(${RUNTIME_LIGHT_DIR}/stdlib/stdlib.cmake) include(${RUNTIME_LIGHT_DIR}/tl/tl.cmake) -include(${RUNTIME_LIGHT_DIR}/state/state.cmake) include(${RUNTIME_LIGHT_DIR}/memory-resource-impl/memory-resource-impl.cmake) set(RUNTIME_LIGHT_SRC ${RUNTIME_LIGHT_CORE_SRC} - ${RUNTIME_LIGHT_COROUTINE_SRC} ${RUNTIME_LIGHT_STDLIB_SRC} ${RUNTIME_LIGHT_SCHEDULER_SRC} ${RUNTIME_LIGHT_SERVER_SRC} ${RUNTIME_LIGHT_ALLOCATOR_SRC} - ${RUNTIME_LIGHT_COROUTINE_SRC} - ${RUNTIME_LIGHT_STATE_SRC} ${RUNTIME_LIGHT_STREAMS_SRC} ${RUNTIME_LIGHT_TL_SRC} ${RUNTIME_LIGHT_UTILS_SRC} ${RUNTIME_LIGHT_MEMORY_RESOURCE_IMPL_SRC} - runtime-light.cpp) + ${RUNTIME_LIGHT_KPHP_COMPONENT_SRC}) set(RUNTIME_SOURCES_FOR_COMP "${RUNTIME_LIGHT_SRC}") configure_file(${BASE_DIR}/compiler/runtime_sources.h.in ${AUTO_DIR}/compiler/runtime_sources.h) @@ -70,10 +66,16 @@ combine_static_runtime_library(kphp-light-runtime-pic k2kphp-rt) # ================================================================================================= +include(${RUNTIME_LIGHT_DIR}/components/confdata/confdata.cmake) + +# ================================================================================================= + file( GLOB_RECURSE KPHP_RUNTIME_ALL_HEADERS RELATIVE ${BASE_DIR} CONFIGURE_DEPENDS "${RUNTIME_LIGHT_DIR}/*.h") +# confdata component has its own state types and is not a part of the kphp runtime +list(FILTER KPHP_RUNTIME_ALL_HEADERS EXCLUDE REGEX "^runtime-light/components/confdata/") file( GLOB_RECURSE KPHP_RUNTIME_COMMON_ALL_HEADERS RELATIVE ${BASE_DIR} diff --git a/runtime-light/server/cli/cli-instance-state.cpp b/runtime-light/server/cli/cli-instance-state.cpp deleted file mode 100644 index cbccadfb38..0000000000 --- a/runtime-light/server/cli/cli-instance-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/server/cli/cli-instance-state.h" - -#include "runtime-light/state/instance-state.h" - -CLIInstanceInstance& CLIInstanceInstance::get() noexcept { - return InstanceState::get().cli_instance_instate; -} diff --git a/runtime-light/server/http/http-server-state.cpp b/runtime-light/server/http/http-server-state.cpp deleted file mode 100644 index 42bca3cb04..0000000000 --- a/runtime-light/server/http/http-server-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/server/http/http-server-state.h" - -#include "runtime-light/state/instance-state.h" - -HttpServerInstanceState& HttpServerInstanceState::get() noexcept { - return InstanceState::get().http_server_instance_state; -} diff --git a/runtime-light/server/http/init-functions.cpp b/runtime-light/server/http/init-functions.cpp index 7ded360ceb..0855f881f1 100644 --- a/runtime-light/server/http/init-functions.cpp +++ b/runtime-light/server/http/init-functions.cpp @@ -29,7 +29,6 @@ #include "runtime-light/k2-platform/k2-api.h" #include "runtime-light/server/http/http-server-state.h" #include "runtime-light/server/http/multipart/multipart.h" -#include "runtime-light/state/instance-state.h" #include "runtime-light/stdlib/component/component-api.h" #include "runtime-light/stdlib/diagnostics/logs.h" #include "runtime-light/stdlib/output/output-state.h" @@ -247,7 +246,7 @@ void init_server(kphp::component::stream&& request_stream, kphp::stl::vector addresses, kphp::coro::async_stack_frame* t namespace kphp::diagnostic::impl { size_t async_backtrace(std::span addresses) noexcept { - if (const auto* instance_state{k2::instance_state()}; instance_state != nullptr) [[likely]] { - const auto& async_stack_root{instance_state->coroutine_instance_state.coroutine_stack_root}; + if (k2::instance_state() == nullptr) [[unlikely]] { + return 0; + } + + const auto& async_stack_root{kphp::coro::instance_state::get().coroutine_stack_root}; - auto* const start_sync_frame{reinterpret_cast(STACK_FRAME_ADDRESS)}; - auto* const stop_sync_frame{async_stack_root.stop_sync_stack_frame}; + auto* const start_sync_frame{reinterpret_cast(STACK_FRAME_ADDRESS)}; + auto* const stop_sync_frame{async_stack_root.stop_sync_stack_frame}; - size_t frames_count{sync_frames(addresses, start_sync_frame, stop_sync_frame)}; - if (frames_count < addresses.size()) { - frames_count += async_frames(addresses.subspan(frames_count), async_stack_root.top_async_stack_frame); - } - return frames_count; + size_t frames_count{sync_frames(addresses, start_sync_frame, stop_sync_frame)}; + if (frames_count < addresses.size()) { + frames_count += async_frames(addresses.subspan(frames_count), async_stack_root.top_async_stack_frame); } - return 0; + return frames_count; } } // namespace kphp::diagnostic::impl diff --git a/runtime-light/stdlib/diagnostics/contextual-tags.cpp b/runtime-light/stdlib/diagnostics/contextual-tags.cpp deleted file mode 100644 index a662e7b2bd..0000000000 --- a/runtime-light/stdlib/diagnostics/contextual-tags.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/diagnostics/contextual-tags.h" - -#include -#include -#include - -#include "runtime-light/k2-platform/k2-api.h" -#include "runtime-light/state/instance-state.h" - -namespace kphp::log { - -std::optional> contextual_tags::try_get() noexcept { - if (auto* instance_state_ptr{k2::instance_state()}; instance_state_ptr != nullptr) [[likely]] { - return instance_state_ptr->instance_tags; - } - return std::nullopt; -} - -} // namespace kphp::log diff --git a/runtime-light/stdlib/diagnostics/error-handling-state.cpp b/runtime-light/stdlib/diagnostics/error-handling-state.cpp deleted file mode 100644 index 78829795b3..0000000000 --- a/runtime-light/stdlib/diagnostics/error-handling-state.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/diagnostics/error-handling-state.h" - -#include -#include -#include - -#include "runtime-common/core/runtime-core.h" -#include "runtime-light/state/component-state.h" -#include "runtime-light/state/instance-state.h" - -ErrorHandlingState::ErrorHandlingState() noexcept { - const auto& component_st{ComponentState::get()}; - const auto& default_level_str{component_st.ini_opts.get_value(string{INI_ERROR_REPORTING_KEY.data(), INI_ERROR_REPORTING_KEY.size()})}; - if (default_level_str.empty() || !default_level_str.is_int()) { - return; - } - - const int64_t default_level{default_level_str.to_int()}; - minimum_log_level = static_cast(SUPPORTED_ERROR_LEVELS & default_level) ? default_level : minimum_log_level; -} - -ErrorHandlingState& ErrorHandlingState::get() noexcept { - return InstanceState::get().error_handling_instance_state; -} - -std::optional> ErrorHandlingState::try_get() noexcept { - if (auto* instance_state_ptr{k2::instance_state()}; instance_state_ptr != nullptr) [[likely]] { - return instance_state_ptr->error_handling_instance_state; - } - return std::nullopt; -} diff --git a/runtime-light/stdlib/file/file-system-state.cpp b/runtime-light/stdlib/file/file-system-state.cpp index e3c31c1749..a6ab7f2ebc 100644 --- a/runtime-light/stdlib/file/file-system-state.cpp +++ b/runtime-light/stdlib/file/file-system-state.cpp @@ -8,7 +8,6 @@ #include "common/php-functions.h" #include "runtime-common/core/runtime-core.h" -#include "runtime-light/state/image-state.h" namespace { @@ -36,7 +35,3 @@ FileSystemImageState::FileSystemImageState() noexcept WRITE_PLUS_MODE.set_reference_counter_to(ExtraRefCnt::for_global_const); APPEND_PLUS_MODE.set_reference_counter_to(ExtraRefCnt::for_global_const); } - -const FileSystemImageState& FileSystemImageState::get() noexcept { - return ImageState::get().file_system_image_state; -} diff --git a/runtime-light/stdlib/file/resource.cpp b/runtime-light/stdlib/file/resource.cpp index f7a8327d75..7ddfad6b6f 100644 --- a/runtime-light/stdlib/file/resource.cpp +++ b/runtime-light/stdlib/file/resource.cpp @@ -7,7 +7,7 @@ #include #include -#include "runtime-light/state/instance-state.h" +#include "runtime-light/components/kphp/state/instance-state.h" namespace kphp::fs { diff --git a/runtime-light/stdlib/fork/fork-state.cpp b/runtime-light/stdlib/fork/fork-state.cpp deleted file mode 100644 index 4655aa3455..0000000000 --- a/runtime-light/stdlib/fork/fork-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/fork/fork-state.h" - -#include "runtime-light/state/instance-state.h" - -ForkInstanceState& ForkInstanceState::get() noexcept { - return InstanceState::get().fork_instance_state; -} diff --git a/runtime-light/stdlib/fork/wait-queue-state.cpp b/runtime-light/stdlib/fork/wait-queue-state.cpp deleted file mode 100644 index 4b51ea7f2c..0000000000 --- a/runtime-light/stdlib/fork/wait-queue-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/fork/wait-queue-state.h" - -#include "runtime-light/state/instance-state.h" - -WaitQueueInstanceState& WaitQueueInstanceState::get() noexcept { - return InstanceState::get().wait_queue_instance_state; -} diff --git a/runtime-light/stdlib/instance-cache/instance-cache-state.cpp b/runtime-light/stdlib/instance-cache/instance-cache-state.cpp deleted file mode 100644 index 15c84e80a2..0000000000 --- a/runtime-light/stdlib/instance-cache/instance-cache-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/instance-cache/instance-cache-state.h" - -#include "runtime-light/state/instance-state.h" - -InstanceCacheInstanceState& InstanceCacheInstanceState::get() noexcept { - return InstanceState::get().instance_cache_instance_state; -} diff --git a/runtime-light/stdlib/job-worker/job-worker-api.cpp b/runtime-light/stdlib/job-worker/job-worker-api.cpp index ec36599895..44ed5a11ee 100644 --- a/runtime-light/stdlib/job-worker/job-worker-api.cpp +++ b/runtime-light/stdlib/job-worker/job-worker-api.cpp @@ -15,7 +15,6 @@ #include "runtime-light/coroutine/task.h" #include "runtime-light/k2-platform/k2-api.h" #include "runtime-light/server/job-worker/job-worker-server-state.h" -#include "runtime-light/state/instance-state.h" #include "runtime-light/stdlib/component/component-api.h" #include "runtime-light/stdlib/fork/fork-functions.h" #include "runtime-light/stdlib/fork/fork-state.h" diff --git a/runtime-light/stdlib/job-worker/job-worker-client-state.cpp b/runtime-light/stdlib/job-worker/job-worker-client-state.cpp deleted file mode 100644 index 3b7921304c..0000000000 --- a/runtime-light/stdlib/job-worker/job-worker-client-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/job-worker/job-worker-client-state.h" - -#include "runtime-light/state/instance-state.h" - -JobWorkerClientInstanceState& JobWorkerClientInstanceState::get() noexcept { - return InstanceState::get().job_worker_client_instance_state; -} diff --git a/runtime-light/stdlib/kml/kml-state.cpp b/runtime-light/stdlib/kml/kml-state.cpp deleted file mode 100644 index 96f061ad86..0000000000 --- a/runtime-light/stdlib/kml/kml-state.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/kml/kml-state.h" - -#include "runtime-light/state/component-state.h" -#include "runtime-light/state/instance-state.h" - -template<> -const KmlComponentState& KmlComponentState::get() noexcept { - return ComponentState::get().kml_component_state; -} - -template<> -KmlComponentState& KmlComponentState::get_mutable() noexcept { - return const_cast(KmlComponentState::get()); -} - -template<> -KmlInstanceState& KmlInstanceState::get() noexcept { - return InstanceState::get().kml_instance_state; -} diff --git a/runtime-light/stdlib/math/math-state.cpp b/runtime-light/stdlib/math/math-state.cpp deleted file mode 100644 index 130ff5bae7..0000000000 --- a/runtime-light/stdlib/math/math-state.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/math/math-state.h" - -#include "runtime-light/state/image-state.h" -#include "runtime-light/state/instance-state.h" - -MathInstanceState& MathInstanceState::get() noexcept { - return InstanceState::get().math_instance_state; -} - -const MathImageState& MathImageState::get() noexcept { - return ImageState::get().math_image_state; -} diff --git a/runtime-light/stdlib/math/random-state.cpp b/runtime-light/stdlib/math/random-state.cpp deleted file mode 100644 index 09388d3910..0000000000 --- a/runtime-light/stdlib/math/random-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/math/random-state.h" - -#include "runtime-light/state/instance-state.h" - -RandomInstanceState& RandomInstanceState::get() noexcept { - return InstanceState::get().random_instance_state; -} diff --git a/runtime-light/stdlib/output/output-state.cpp b/runtime-light/stdlib/output/output-state.cpp deleted file mode 100644 index c03f5165ff..0000000000 --- a/runtime-light/stdlib/output/output-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/output/output-state.h" - -#include "runtime-light/state/instance-state.h" - -OutputInstanceState& OutputInstanceState::get() noexcept { - return InstanceState::get().output_instance_state; -} diff --git a/runtime-light/stdlib/rpc/rpc-client-state.cpp b/runtime-light/stdlib/rpc/rpc-client-state.cpp deleted file mode 100644 index e4ebc32e9a..0000000000 --- a/runtime-light/stdlib/rpc/rpc-client-state.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/rpc/rpc-client-state.h" - -#include "runtime-light/state/image-state.h" -#include "runtime-light/state/instance-state.h" - -RpcClientInstanceState& RpcClientInstanceState::get() noexcept { - return InstanceState::get().rpc_client_instance_state; -} - -const RpcImageState& RpcImageState::get() noexcept { - return ImageState::get().rpc_image_state; -} - -RpcImageState& RpcImageState::get_mutable() noexcept { - return ImageState::get_mutable().rpc_image_state; -} diff --git a/runtime-light/stdlib/rpc/rpc-queue-state.cpp b/runtime-light/stdlib/rpc/rpc-queue-state.cpp deleted file mode 100644 index a346863a01..0000000000 --- a/runtime-light/stdlib/rpc/rpc-queue-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/rpc/rpc-queue-state.h" - -#include "runtime-light/state/instance-state.h" - -RpcQueueInstanceState& RpcQueueInstanceState::get() noexcept { - return InstanceState::get().rpc_queue_instance_state; -} diff --git a/runtime-light/stdlib/serialization/serialization-state.cpp b/runtime-light/stdlib/serialization/serialization-state.cpp deleted file mode 100644 index 29f6632898..0000000000 --- a/runtime-light/stdlib/serialization/serialization-state.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/serialization/serialization-state.h" - -#include "runtime-light/state/image-state.h" -#include "runtime-light/state/instance-state.h" - -SerializationInstanceState& SerializationInstanceState::get() noexcept { - return InstanceState::get().serialization_instance_state; -} - -const SerializationImageState& SerializationImageState::get() noexcept { - return ImageState::get().serialization_image_state; -} diff --git a/runtime-light/stdlib/server/args-functions.h b/runtime-light/stdlib/server/args-functions.h index bf9c93b9f3..bd4544950d 100644 --- a/runtime-light/stdlib/server/args-functions.h +++ b/runtime-light/stdlib/server/args-functions.h @@ -5,7 +5,7 @@ #pragma once #include "runtime-common/core/runtime-core.h" -#include "runtime-light/state/component-state.h" +#include "runtime-light/components/kphp/state/component-state.h" inline Optional f$ini_get(const string& key) noexcept { const auto& component_st{ComponentState::get()}; diff --git a/runtime-light/stdlib/server/common-functions.h b/runtime-light/stdlib/server/common-functions.h index e5716cab42..f622501743 100644 --- a/runtime-light/stdlib/server/common-functions.h +++ b/runtime-light/stdlib/server/common-functions.h @@ -7,9 +7,9 @@ #include #include "runtime-common/core/runtime-core.h" +#include "runtime-light/components/kphp/state/instance-state.h" #include "runtime-light/coroutine/task.h" #include "runtime-light/server/http/http-server-state.h" -#include "runtime-light/state/instance-state.h" #include "runtime-light/stdlib/diagnostics/logs.h" #include "runtime-light/stdlib/fork/fork-functions.h" #include "runtime-light/stdlib/system/system-functions.h" diff --git a/runtime-light/stdlib/server/handler-functions.h b/runtime-light/stdlib/server/handler-functions.h index 49c562c045..41c9981b0c 100644 --- a/runtime-light/stdlib/server/handler-functions.h +++ b/runtime-light/stdlib/server/handler-functions.h @@ -8,9 +8,9 @@ #include #include +#include "runtime-light/components/kphp/state/instance-state.h" #include "runtime-light/coroutine/task.h" #include "runtime-light/coroutine/type-traits.h" -#include "runtime-light/state/instance-state.h" #include "runtime-light/stdlib/diagnostics/logs.h" template diff --git a/runtime-light/stdlib/stdlib.cmake b/runtime-light/stdlib/stdlib.cmake index 92f67cd6b4..8776da4dc4 100644 --- a/runtime-light/stdlib/stdlib.cmake +++ b/runtime-light/stdlib/stdlib.cmake @@ -2,50 +2,30 @@ prepend( RUNTIME_LIGHT_STDLIB_SRC stdlib/ confdata/confdata-functions.cpp - confdata/confdata-state.cpp crypto/crypto-functions.cpp - curl/curl-state.cpp - web-transfer-lib/web-state.cpp diagnostics/backtrace.cpp - diagnostics/contextual-tags.cpp - diagnostics/error-handling-state.cpp diagnostics/php-assert.cpp file/file-system-state.cpp file/file-system-functions.cpp file/resource.cpp - fork/fork-state.cpp fork/fork-storage.cpp - fork/wait-queue-state.cpp - instance-cache/instance-cache-state.cpp job-worker/job-worker-api.cpp - job-worker/job-worker-client-state.cpp - kml/kml-state.cpp - math/random-state.cpp - math/math-state.cpp output/output-buffer.cpp - output/output-state.cpp output/print-functions.cpp rpc/rpc-api.cpp - rpc/rpc-client-state.cpp rpc/rpc-extra-headers.cpp rpc/rpc-extra-info.cpp - rpc/rpc-queue-state.cpp rpc/rpc-tl-builtins.cpp rpc/rpc-tl-error.cpp rpc/rpc-tl-query.cpp rpc/rpc-tl-request.cpp - serialization/serialization-state.cpp server/http-functions.cpp string/regex-functions.cpp - string/regex-state.cpp - string/string-state.cpp system/system-functions.cpp - system/system-state.cpp time/date-interval.cpp time/date-time.cpp time/date-time-immutable.cpp time/time-functions.cpp - time/time-state.cpp time/timelib-functions.cpp zlib/zlib-functions.cpp zstd/zstd-functions.cpp) diff --git a/runtime-light/stdlib/string/regex-state.cpp b/runtime-light/stdlib/string/regex-state.cpp deleted file mode 100644 index 39e14265af..0000000000 --- a/runtime-light/stdlib/string/regex-state.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/string/regex-state.h" - -#include "runtime-light/state/instance-state.h" - -RegexInstanceState& RegexInstanceState::get() noexcept { - return InstanceState::get().regex_instance_state; -} - -const RegexImageState& RegexImageState::get() noexcept { - return ImageState::get().regex_image_state; -} - -RegexImageState& RegexImageState::get_mutable() noexcept { - return ImageState::get_mutable().regex_image_state; -} diff --git a/runtime-light/stdlib/string/string-state.cpp b/runtime-light/stdlib/string/string-state.cpp deleted file mode 100644 index 5d45cb722b..0000000000 --- a/runtime-light/stdlib/string/string-state.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/string/string-state.h" - -#include "runtime-light/state/image-state.h" -#include "runtime-light/state/instance-state.h" - -StringInstanceState& StringInstanceState::get() noexcept { - return InstanceState::get().string_instance_state; -} - -const StringImageState& StringImageState::get() noexcept { - return ImageState::get().string_image_state; -} diff --git a/runtime-light/stdlib/system/system-functions.h b/runtime-light/stdlib/system/system-functions.h index 1b1845ce11..09cad7370a 100644 --- a/runtime-light/stdlib/system/system-functions.h +++ b/runtime-light/stdlib/system/system-functions.h @@ -26,13 +26,13 @@ #include "runtime-common/core/allocator/script-malloc-interface.h" #include "runtime-common/core/runtime-core.h" #include "runtime-common/stdlib/serialization/json-functions.h" +#include "runtime-light/components/kphp/state/component-state.h" +#include "runtime-light/components/kphp/state/image-state.h" +#include "runtime-light/components/kphp/state/instance-state.h" #include "runtime-light/core/globals/php-script-globals.h" #include "runtime-light/coroutine/io-scheduler.h" #include "runtime-light/coroutine/task.h" #include "runtime-light/k2-platform/k2-api.h" -#include "runtime-light/state/component-state.h" -#include "runtime-light/state/image-state.h" -#include "runtime-light/state/instance-state.h" #include "runtime-light/stdlib/diagnostics/contextual-tags.h" #include "runtime-light/stdlib/diagnostics/logs.h" #include "runtime-light/stdlib/fork/fork-functions.h" diff --git a/runtime-light/stdlib/system/system-state.cpp b/runtime-light/stdlib/system/system-state.cpp deleted file mode 100644 index 34269aeadf..0000000000 --- a/runtime-light/stdlib/system/system-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2024 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/system/system-state.h" - -#include "runtime-light/state/instance-state.h" - -SystemInstanceState& SystemInstanceState::get() noexcept { - return InstanceState::get().system_instance_state; -} diff --git a/runtime-light/stdlib/time/time-state.cpp b/runtime-light/stdlib/time/time-state.cpp deleted file mode 100644 index 637f3929d1..0000000000 --- a/runtime-light/stdlib/time/time-state.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/time/time-state.h" - -#include "runtime-light/state/image-state.h" -#include "runtime-light/state/instance-state.h" - -TimeInstanceState& TimeInstanceState::get() noexcept { - return InstanceState::get().time_instance_state; -} - -const TimeImageState& TimeImageState::get() noexcept { - return ImageState::get().time_image_state; -} - -TimeImageState& TimeImageState::get_mutable() noexcept { - return ImageState::get_mutable().time_image_state; -} diff --git a/runtime-light/stdlib/visitors/array-visitors.h b/runtime-light/stdlib/visitors/array-visitors.h index c6f7b85121..e0cde9b84f 100644 --- a/runtime-light/stdlib/visitors/array-visitors.h +++ b/runtime-light/stdlib/visitors/array-visitors.h @@ -5,7 +5,7 @@ #pragma once #include "runtime-common/core/runtime-core.h" -#include "runtime-light/state/image-state.h" +#include "runtime-light/components/kphp/state/image-state.h" #include "runtime-light/stdlib/visitors/shape-visitors.h" class ToArrayVisitor { diff --git a/runtime-light/stdlib/web-transfer-lib/web-state.cpp b/runtime-light/stdlib/web-transfer-lib/web-state.cpp deleted file mode 100644 index 96d1fdb523..0000000000 --- a/runtime-light/stdlib/web-transfer-lib/web-state.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#include "runtime-light/stdlib/web-transfer-lib/web-state.h" - -#include "runtime-light/state/instance-state.h" - -WebInstanceState& WebInstanceState::get() noexcept { - return InstanceState::get().web_instance_state; -}