diff --git a/BUILD.gn b/BUILD.gn index f30ca7fdd9670d89445ed7ff4d29800084bc8fce..20bd2c161c305d1126b1410afec205ef443571ac 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -24,6 +24,12 @@ group("ark_packages") { } } +group("ark_packages_for_windows") { + deps = [ + "$ark_root/runtime:libarkruntime(//build/toolchain/mingw:mingw_x86_64)", + ] +} + group("ark_host_linux_tools_packages") { if (host_os != "mac") { deps = [ diff --git a/assembler/BUILD.gn b/assembler/BUILD.gn index ecf04b5de7c7e241fcce94cab6f041a2863b6470..b44863256896ec12fdf22e2475be5000d11209d4 100644 --- a/assembler/BUILD.gn +++ b/assembler/BUILD.gn @@ -68,7 +68,6 @@ ohos_shared_library("libarkassembler") { if (!is_standard_system) { relative_install_dir = "ark" } - output_extension = "so" subsystem_name = "ark" } diff --git a/disassembler/BUILD.gn b/disassembler/BUILD.gn index fa244bc2038f52911abd3cc0c1a1183557c678ed..c88e46ba90e8d94969edb151485b1e6f7047937a 100644 --- a/disassembler/BUILD.gn +++ b/disassembler/BUILD.gn @@ -55,7 +55,6 @@ ohos_shared_library("arkdisassembler") { if (!is_standard_system) { relative_install_dir = "ark" } - output_extension = "so" subsystem_name = "ark" } diff --git a/gn/ark-third-party/securec/BUILD.gn b/gn/ark-third-party/securec/BUILD.gn index 8479aad074e214f8624c6ef2feae8562163f4d82..60b0f4406d9c0426bf2abb55af2c8f4a8b077672 100644 --- a/gn/ark-third-party/securec/BUILD.gn +++ b/gn/ark-third-party/securec/BUILD.gn @@ -86,6 +86,4 @@ ohos_shared_library("libc_secshared") { "-D_INC_STDLIB_S", "-D_INC_MEMORY_S", ] - - output_extension = "so" } diff --git a/libpandabase/BUILD.gn b/libpandabase/BUILD.gn index d5404d9b59b82d80b7f4497b478a1c7dba25f1e0..a99ab85448b82f064d9bdbc9921892d756470b47 100644 --- a/libpandabase/BUILD.gn +++ b/libpandabase/BUILD.gn @@ -40,6 +40,7 @@ if (is_mingw) { "$ark_root/libpandabase/mem/arena.cpp", "$ark_root/libpandabase/mem/arena_allocator.cpp", "$ark_root/libpandabase/mem/base_mem_stats.cpp", + "$ark_root/libpandabase/mem/code_allocator.cpp", "$ark_root/libpandabase/mem/mem_config.cpp", "$ark_root/libpandabase/mem/pool_manager.cpp", "$ark_root/libpandabase/mem/pool_map.cpp", @@ -51,11 +52,14 @@ if (is_mingw) { "$ark_root/libpandabase/os/windows/file.cpp", "$ark_root/libpandabase/os/windows/mem.cpp", "$ark_root/libpandabase/os/windows/thread.cpp", + "$ark_root/libpandabase/os/windows/time.cpp", "$ark_root/libpandabase/trace/windows/trace.cpp", "$ark_root/libpandabase/utils/dfx.cpp", "$ark_root/libpandabase/utils/json_parser.cpp", "$ark_root/libpandabase/utils/logger.cpp", "$ark_root/libpandabase/utils/utf.cpp", + "$ark_root/libpandabase/utils/time.cpp", + "$ark_root/libpandabase/utils/type_converter.cpp", ] } else { libarkbase_sources = [ @@ -129,7 +133,6 @@ ohos_shared_library("libarkbase") { deps = libarkbase_deps - output_extension = "so" if (!is_standard_system) { relative_install_dir = "ark" } diff --git a/libpandabase/macros.h b/libpandabase/macros.h index 13ba4f0ae68e6f9d37925c108722ca03cceda4d8..2d85158d15facad6e11c8aef159403048affab6d 100644 --- a/libpandabase/macros.h +++ b/libpandabase/macros.h @@ -48,7 +48,11 @@ #endif // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#ifndef PANDA_TARGET_WINDOWS #define PANDA_PUBLIC_API __attribute__((visibility ("default"))) +#else +#define PANDA_PUBLIC_API __declspec(dllexport) +#endif // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define MEMBER_OFFSET(T, F) offsetof(T, F) diff --git a/libpandabase/os/native_stack.h b/libpandabase/os/native_stack.h index 536b252e60e33fc8ee296e49ecf5045a2f145fdf..bf0ef0282657c00a1e749434366fa4ce30fea090 100644 --- a/libpandabase/os/native_stack.h +++ b/libpandabase/os/native_stack.h @@ -25,8 +25,8 @@ namespace panda::os::native_stack { -const auto g_PandaThreadSigmask = pthread_sigmask; // NOLINT(readability-identifier-naming) #if defined(PANDA_TARGET_UNIX) +const auto g_PandaThreadSigmask = pthread_sigmask; // NOLINT(readability-identifier-naming) using DumpUnattachedThread = panda::os::unix::native_stack::DumpUnattachedThread; const auto DumpKernelStack = panda::os::unix::native_stack::DumpKernelStack; // NOLINT(readability-identifier-naming) const auto GetNativeThreadNameForFile = // NOLINT(readability-identifier-naming) diff --git a/libpandabase/os/thread.h b/libpandabase/os/thread.h index 05cb7830730038425b05fbee209e9bd39bff1a73..f4e4ca1a9bbcc7e4371a449fb268ace44d5dfe5e 100644 --- a/libpandabase/os/thread.h +++ b/libpandabase/os/thread.h @@ -22,6 +22,7 @@ #include #include #include +#include namespace panda::os::thread { @@ -29,15 +30,22 @@ using ThreadId = uint32_t; using native_handle_type = std::thread::native_handle_type; ThreadId GetCurrentThreadId(); +#ifdef PANDA_TARGET_UNIX int SetPriority(int thread_id, int prio); int GetPriority(int thread_id); int SetThreadName(native_handle_type pthread_id, const char *name); +void ThreadJoin(native_handle_type pthread_id, void **retval); +#else +int SetPriority(void *hthread, int prio); +int GetPriority(void *hthread); +int SetThreadName(std::thread::id pthread_id, const char *name); +void ThreadJoin(pthread_t pthread_id, void **retval); +#endif native_handle_type GetNativeHandle(); void Yield(); void NativeSleep(unsigned int ms); void ThreadDetach(native_handle_type pthread_id); void ThreadExit(void *retval); -void ThreadJoin(native_handle_type pthread_id, void **retval); // Templated functions need to be defined here to be accessible everywhere @@ -108,7 +116,11 @@ static void *ProxyFunc(void *args) template native_handle_type ThreadStart(Func *func, Args... args) { +#ifndef PANDA_TARGET_WINDOWS native_handle_type tid; +#else + pthread_t tid; +#endif auto args_tuple = std::make_tuple(func, std::move(args)...); internal::SharedPtrStruct *ptr = nullptr; { @@ -124,7 +136,11 @@ native_handle_type ThreadStart(Func *func, Args... args) pthread_create(&tid, nullptr, &internal::ProxyFunc::value>, static_cast(ptr)); +#ifndef PANDA_TARGET_WINDOWS return tid; +#else + return reinterpret_cast(tid); +#endif } } // namespace panda::os::thread diff --git a/libpandabase/os/windows/mem.cpp b/libpandabase/os/windows/mem.cpp index 7054e5ba0aea3f893b1e5b09c5642a2fc75213bb..c1a519b30f2050b636502df33e7ca11fe04fb49a 100644 --- a/libpandabase/os/windows/mem.cpp +++ b/libpandabase/os/windows/mem.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #define MAP_FAILED (reinterpret_cast(-1)) @@ -158,6 +159,17 @@ BytePtr MapFile(file::File file, uint32_t prot, uint32_t flags, size_t size, siz return BytePtr(static_cast(result) + offset, size, MmapDeleter); } +std::optional MakeMemReadExec(void *mem, size_t size) +{ + PDWORD old = nullptr; + // NOLINTNEXTLINE(hicpp-signed-bitwise) + int r = VirtualProtect(mem, size, MMAP_PROT_EXEC | MMAP_PROT_READ, old); + if (r != 0) { + return Error(errno); + } + return {}; +} + uint32_t GetPageSize() { constexpr size_t PAGE_SIZE = 4096; @@ -207,6 +219,15 @@ void *MapRWAnonymousWithAlignmentRaw(size_t size, size_t aligment_in_bytes, bool return reinterpret_cast(aligned_mem); } +uintptr_t AlignDownToPageSize(uintptr_t addr) +{ + SYSTEM_INFO sysInfo; + GetSystemInfo(&sysInfo); + const size_t SYS_PAGE_SIZE = sysInfo.dwPageSize; + addr &= ~(SYS_PAGE_SIZE - 1); + return addr; +} + void *AlignedAlloc(size_t alignment_in_bytes, size_t size) { size_t aligned_size = (size + alignment_in_bytes - 1) & ~(alignment_in_bytes - 1); @@ -234,4 +255,9 @@ std::optional TagAnonymousMemory([[maybe_unused]] const void *mem, [[mayb return {}; } +size_t GetNativeBytesFromMallinfo() +{ + return DEFAULT_NATIVE_BYTES_FROM_MALLINFO; +} + } // namespace panda::os::mem diff --git a/libpandabase/os/windows/thread.cpp b/libpandabase/os/windows/thread.cpp index 76292e80d79774f70dffa6b032b6fdaee6973926..77b7c1338383d1532db0564a34ccd924ce3e8db0 100644 --- a/libpandabase/os/windows/thread.cpp +++ b/libpandabase/os/windows/thread.cpp @@ -16,6 +16,7 @@ #include "os/thread.h" #include +#include namespace panda::os::thread { @@ -24,4 +25,35 @@ ThreadId GetCurrentThreadId() return static_cast(std::hash()(std::this_thread::get_id())); } +int SetPriority(void *hthread, int prio) +{ + return SetThreadPriority(hthread, prio); +} + +int GetPriority(void *hthread) +{ + return GetThreadPriority(hthread); +} + +int SetThreadName(std::thread::id pthread_id, const char *name) +{ + ASSERT(pthread_id != 0); + return pthread_setname_np(static_cast(std::hash{}(pthread_id)), name); +} + +void Yield() +{ + std::this_thread::yield(); +} + +void NativeSleep(unsigned int ms) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(ms)); +} + +void ThreadJoin(pthread_t pthread_id, void **retval) +{ + pthread_join(pthread_id, retval); +} + } // namespace panda::os::thread diff --git a/libpandabase/os/windows/time.cpp b/libpandabase/os/windows/time.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f85451943f84f52c9d7d8783b236872a25b472ee --- /dev/null +++ b/libpandabase/os/windows/time.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "os/time.h" +#include + +namespace panda::os::time { +template +static uint64_t GetClockTime(clockid_t clock) +{ + struct timespec time = {0, 0}; + if (clock_gettime(clock, &time) != -1) { + auto duration = std::chrono::seconds {time.tv_sec} + std::chrono::nanoseconds {time.tv_nsec}; + return std::chrono::duration_cast(duration).count(); + } + return 0; +} + +/** + * Return current time in nanoseconds + */ +uint64_t GetClockTimeInMicro() +{ + return GetClockTime(CLOCK_MONOTONIC); +} + +/** + * Return current time in milliseconds + */ +uint64_t GetClockTimeInMilli() +{ + return GetClockTime(CLOCK_MONOTONIC); +} + +/** + * Return thread CPU time in nanoseconds + */ +uint64_t GetClockTimeInThreadCpuTime() +{ + return GetClockTime(CLOCK_THREAD_CPUTIME_ID); +} +} // namespace panda::os::time diff --git a/libpandabase/os/windows/time.h b/libpandabase/os/windows/time.h new file mode 100644 index 0000000000000000000000000000000000000000..5cde7da2aee9199e9e03647db24d18585be9e76c --- /dev/null +++ b/libpandabase/os/windows/time.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PANDA_LIBPANDABASE_OS_WINDOWS_TIME_H_ +#define PANDA_LIBPANDABASE_OS_WINDOWS_TIME_H_ + +#include + +namespace panda::os::windows::time { + +/** + * Return current time in nanoseconds + */ +uint64_t GetClockTimeInMicro(); + +/** + * Return current time in milliseconds + */ +uint64_t GetClockTimeInMilli(); + +/** + * Thread Cpu Time in nanoseconds + */ +uint64_t GetClockTimeInThreadCpuTime(); + +} // namespace panda::os::unix::time + +#endif // PANDA_LIBPANDABASE_OS_WINDOWS_TIME_H_ diff --git a/libpandafile/BUILD.gn b/libpandafile/BUILD.gn index 6d9b5e656ff6f32dff21761fc56375ed431150c6..fef96edfa9b5889bfe3e02a8e2650ed2bdaf61fe 100644 --- a/libpandafile/BUILD.gn +++ b/libpandafile/BUILD.gn @@ -78,7 +78,6 @@ ohos_shared_library("libarkfile") { if (!is_standard_system) { relative_install_dir = "ark" } - output_extension = "so" subsystem_name = "ark" } diff --git a/libpandafile/external/BUILD.gn b/libpandafile/external/BUILD.gn index 8ef779789d653bec0a04ae003551de583c3c6c5d..6a0bfcde0ef410e940db5925bdd6247411d2458a 100644 --- a/libpandafile/external/BUILD.gn +++ b/libpandafile/external/BUILD.gn @@ -39,7 +39,6 @@ ohos_shared_library("libarkfileExt") { if (!is_standard_system) { relative_install_dir = "ark" } - output_extension = "so" subsystem_name = "ark" } @@ -68,6 +67,5 @@ ohos_shared_library("libarksupport") { if (!is_standard_system) { relative_install_dir = "ark" } - output_extension = "so" subsystem_name = "ark" } diff --git a/libpandafile/panda_cache.h b/libpandafile/panda_cache.h index 1be7b037efbc4337f2e36793109257fe7395f06c..20164d627da8ec5c23590a87fedf3281eb3c7eb0 100644 --- a/libpandafile/panda_cache.h +++ b/libpandafile/panda_cache.h @@ -79,6 +79,7 @@ public: inline Method *GetMethodFromCache(File::EntityId id) const { +#ifdef PANDA_TARGET_UNIX uint32_t index = GetMethodIndex(id); auto *pair_ptr = reinterpret_cast *>(reinterpret_cast(&(method_cache_[index]))); @@ -87,11 +88,13 @@ public: if (pair.id_ == id) { return pair.ptr_; } +#endif return nullptr; } inline void SetMethodCache(File::EntityId id, Method *method) { +#ifdef PANDA_TARGET_UNIX MethodCachePair pair; pair.id_ = id; pair.ptr_ = method; @@ -100,10 +103,12 @@ public: reinterpret_cast *>(reinterpret_cast(&(method_cache_[index]))); TSAN_ANNOTATE_HAPPENS_BEFORE(pair_ptr); pair_ptr->store(pair, std::memory_order_release); +#endif } inline Field *GetFieldFromCache(File::EntityId id) const { +#ifdef PANDA_TARGET_UNIX uint32_t index = GetFieldIndex(id); auto *pair_ptr = reinterpret_cast *>(reinterpret_cast(&(field_cache_[index]))); @@ -112,11 +117,13 @@ public: if (pair.id_ == id) { return pair.ptr_; } +#endif return nullptr; } inline void SetFieldCache(File::EntityId id, Field *field) { +#ifdef PANDA_TARGET_UNIX uint32_t index = GetFieldIndex(id); auto *pair_ptr = reinterpret_cast *>(reinterpret_cast(&(field_cache_[index]))); @@ -125,10 +132,12 @@ public: pair.ptr_ = field; TSAN_ANNOTATE_HAPPENS_BEFORE(pair_ptr); pair_ptr->store(pair, std::memory_order_release); +#endif } inline Class *GetClassFromCache(File::EntityId id) const { +#ifdef PANDA_TARGET_UNIX uint32_t index = GetClassIndex(id); auto *pair_ptr = reinterpret_cast *>(reinterpret_cast(&(class_cache_[index]))); @@ -137,11 +146,13 @@ public: if (pair.id_ == id) { return pair.ptr_; } +#endif return nullptr; } inline void SetClassCache(File::EntityId id, Class *clazz) { +#ifdef PANDA_TARGET_UNIX ClassCachePair pair; pair.id_ = id; pair.ptr_ = clazz; @@ -150,11 +161,13 @@ public: reinterpret_cast *>(reinterpret_cast(&(class_cache_[index]))); TSAN_ANNOTATE_HAPPENS_BEFORE(pair_ptr); pair_ptr->store(pair, std::memory_order_release); +#endif } template bool EnumerateCachedClasses(const Callback &cb) { +#ifdef PANDA_TARGET_UNIX for (uint32_t i = 0; i < CLASS_CACHE_SIZE; i++) { auto *pair_ptr = reinterpret_cast *>(reinterpret_cast(&(class_cache_[i]))); @@ -166,6 +179,7 @@ public: } } } +#endif return true; } diff --git a/libziparchive/BUILD.gn b/libziparchive/BUILD.gn index 7b050e19ef62ae3ebdc3029c5957f2b6dd73ed8a..1bbe377766bf0f5be14068b03225345b6d6cafc2 100644 --- a/libziparchive/BUILD.gn +++ b/libziparchive/BUILD.gn @@ -52,7 +52,6 @@ ohos_shared_library("libarkziparchive") { if (!is_standard_system) { relative_install_dir = "ark" } - output_extension = "so" subsystem_name = "ark" } diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index eef472101927ba6bfe6dcaad262d677f542829c5..6c9096d9d725ab591c8f74c85a4a90184d176ac7 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -75,7 +75,6 @@ ohos_static_library("libarkruntime_static") { "class_linker_extension.cpp", "coretypes/array.cpp", "coretypes/string.cpp", - "dprofiler/dprofiler.cpp", "dyn_class_linker_extension.cpp", "entrypoints/entrypoints.cpp", "exceptions.cpp", @@ -142,7 +141,6 @@ ohos_static_library("libarkruntime_static") { "profilesaver/profile_saver.cpp", "runtime.cpp", "runtime_helpers.cpp", - "signal_handler.cpp", "stack_walker.cpp", "string_table.cpp", "thread.cpp", @@ -158,6 +156,12 @@ ohos_static_library("libarkruntime_static") { "tooling/pt_thread.cpp", "vtable_builder.cpp", ] + if (is_linux) { + sources += [ + "dprofiler/dprofiler.cpp", + "signal_handler.cpp", + ] + } if (current_cpu == "arm") { sources += [ "arch/arm/interpreter_support.S", @@ -214,7 +218,6 @@ ohos_static_library("libarkruntime_static") { deps = [ ":arkruntime_header_deps", ":arkruntime_interpreter_impl", - "$ark_root/dprof:libdprof", "$ark_root/libpandabase:libarkbase", "$ark_root/libpandafile:libarkfile", "$ark_root/libpandafile:libarkfile_type_gen_h", @@ -223,6 +226,12 @@ ohos_static_library("libarkruntime_static") { sdk_libc_secshared_dep, ] + if (is_linux) { + deps += [ + "$ark_root/dprof:libdprof", + ] + } + if (is_standard_system) { cflags_cc = [ "-fvisibility=hidden" ] } @@ -250,14 +259,12 @@ ohos_static_library("libarkruntime_static") { ldflags = [ "-latomic" ] } - output_extension = "a" subsystem_name = "ark" } ohos_shared_library("libarkruntime") { deps = [ ":libarkruntime_static" ] - output_extension = "so" if (!is_standard_system) { relative_install_dir = "ark" } diff --git a/runtime/arch/amd64/interpreter_support.S b/runtime/arch/amd64/interpreter_support.S index bae94a8fc509e7794b300dd41798242f81d18fba..85ebb21f4835e8c753cbe3145949633c4991ad84 100644 --- a/runtime/arch/amd64/interpreter_support.S +++ b/runtime/arch/amd64/interpreter_support.S @@ -13,7 +13,9 @@ * limitations under the License. */ +#ifndef PANDA_TARGET_WINDOWS .type ExecuteImplStub, @function +#endif .global ExecuteImplStub .balign 16 ExecuteImplStub: diff --git a/runtime/arch/asm_support.cpp b/runtime/arch/asm_support.cpp index 9e28ab670ecbbc6345c53d64716dcf281e35e4ee..8668843be3fa5d92b38c524470c87c9a4e23beb9 100644 --- a/runtime/arch/asm_support.cpp +++ b/runtime/arch/asm_support.cpp @@ -38,10 +38,12 @@ static_assert(FRAME_SLOT_OFFSET == 80U); static_assert(FRAME_TAG_OFFSET == 88U); #endif +#ifndef PANDA_TARGET_WINDOWS extern "C" ManagedThread *GetCurrentThread() { return ManagedThread::GetCurrent(); } +#endif extern "C" void AsmUnreachable() { diff --git a/runtime/bridge/arch/amd64/compiled_code_to_interpreter_bridge_amd64.S b/runtime/bridge/arch/amd64/compiled_code_to_interpreter_bridge_amd64.S index 21d5a3186ca8edca77fa9382ee45f2ef1e77c055..cb3bbea8f126ad32d2778c10ffb90f66e73ebefb 100644 --- a/runtime/bridge/arch/amd64/compiled_code_to_interpreter_bridge_amd64.S +++ b/runtime/bridge/arch/amd64/compiled_code_to_interpreter_bridge_amd64.S @@ -30,7 +30,9 @@ .extern IncrementHotnessCounter .global CompiledCodeToInterpreterBridge +#ifndef PANDA_TARGET_WINDOWS .type CompiledCodeToInterpreterBridge, %function +#endif CompiledCodeToInterpreterBridge: CFI_STARTPROC CFI_DEF_CFA(rsp, 8) diff --git a/runtime/bridge/arch/amd64/compiled_code_to_interpreter_bridge_dyn_amd64.S b/runtime/bridge/arch/amd64/compiled_code_to_interpreter_bridge_dyn_amd64.S index f006991da0cd5e3ae403a604d4dc04c2250c1f50..1151797d9ac07666df8387aa20cf6722ecb65ab8 100644 --- a/runtime/bridge/arch/amd64/compiled_code_to_interpreter_bridge_dyn_amd64.S +++ b/runtime/bridge/arch/amd64/compiled_code_to_interpreter_bridge_dyn_amd64.S @@ -29,7 +29,9 @@ // CompiledCodeToInterpreterBridgeDyn(Method* method, uint32_t num_args, int64_t func_obj, int64_t func_tag, int64_t arg_i, int64_t tag_i, ...) .global CompiledCodeToInterpreterBridgeDyn +#ifndef PANDA_TARGET_WINDOWS .type CompiledCodeToInterpreterBridgeDyn, %function +#endif CompiledCodeToInterpreterBridgeDyn: CFI_STARTPROC CFI_DEF_CFA(rsp, 8) diff --git a/runtime/bridge/arch/amd64/compiled_code_to_runtime_bridge_amd64.S b/runtime/bridge/arch/amd64/compiled_code_to_runtime_bridge_amd64.S index 273d7e8d2db1d2829bd545cc3e7ed58762d0f6c3..e67c02a80e40853575d345629d17a292cd92c6c4 100644 --- a/runtime/bridge/arch/amd64/compiled_code_to_runtime_bridge_amd64.S +++ b/runtime/bridge/arch/amd64/compiled_code_to_runtime_bridge_amd64.S @@ -17,7 +17,9 @@ .macro ENTRYPOINT name, entry, paramsnum .global \name +#ifndef PANDA_TARGET_WINDOWS .type \name, %function +#endif \name: CFI_STARTPROC CFI_DEF_CFA(rsp, 8) diff --git a/runtime/bridge/arch/amd64/interpreter_to_compiled_code_bridge_amd64.S b/runtime/bridge/arch/amd64/interpreter_to_compiled_code_bridge_amd64.S index 0090d82e866549f3cf405fec29f059e2b0abce7d..d1106b86471f2f044f4a34250cfe797477f6ef8f 100644 --- a/runtime/bridge/arch/amd64/interpreter_to_compiled_code_bridge_amd64.S +++ b/runtime/bridge/arch/amd64/interpreter_to_compiled_code_bridge_amd64.S @@ -261,7 +261,9 @@ // void InterpreterToCompiledCodeBridge(const BytecodeInstruction* insn, const Frame *iframe, const Method *method, ManagedThread* thread) .global InterpreterToCompiledCodeBridge +#ifndef PANDA_TARGET_WINDOWS .type InterpreterToCompiledCodeBridge, %function +#endif InterpreterToCompiledCodeBridge: CFI_STARTPROC CFI_DEF_CFA(rsp, 8) @@ -450,7 +452,9 @@ InterpreterToCompiledCodeBridge: // DecodedTaggedValue InvokeCompiledCodeWithArguments(const int64_t* args, const Frame *iframe, const Method *method, ManagedThread* thread) .global InvokeCompiledCodeWithArgArray +#ifndef PANDA_TARGET_WINDOWS .type InvokeCompiledCodeWithArgArray, %function +#endif InvokeCompiledCodeWithArgArray: CFI_STARTPROC CFI_DEF_CFA(rsp, 8) diff --git a/runtime/bridge/arch/amd64/interpreter_to_compiled_code_bridge_dyn_amd64.S b/runtime/bridge/arch/amd64/interpreter_to_compiled_code_bridge_dyn_amd64.S index 6183b71cdb807a4c8a93b4dc5d367b85b0a5fcf0..d71c33484805726025eb882594803845167a28a8 100644 --- a/runtime/bridge/arch/amd64/interpreter_to_compiled_code_bridge_dyn_amd64.S +++ b/runtime/bridge/arch/amd64/interpreter_to_compiled_code_bridge_dyn_amd64.S @@ -21,7 +21,9 @@ // const Method*, %rdx // ManagedThread* thread) %rcx .global InterpreterToCompiledCodeBridgeDyn +#ifndef PANDA_TARGET_WINDOWS .type InterpreterToCompiledCodeBridgeDyn, %function +#endif InterpreterToCompiledCodeBridgeDyn: CFI_STARTPROC CFI_DEF_CFA(rsp, 8) @@ -125,7 +127,9 @@ InterpreterToCompiledCodeBridgeDyn: // const Method*, %rcx // ManagedThread* thread) %r8 .global InvokeCompiledCodeWithArgArrayDyn +#ifndef PANDA_TARGET_WINDOWS .type InvokeCompiledCodeWithArgArrayDyn, %function +#endif InvokeCompiledCodeWithArgArrayDyn: CFI_STARTPROC CFI_DEF_CFA(rsp, 8) diff --git a/runtime/class_linker.cpp b/runtime/class_linker.cpp index df73d2b1b897aac9661a8ec12687de9c45550368..f5c7e48f8ee867e345a516e283dc2d3d125abdef 100644 --- a/runtime/class_linker.cpp +++ b/runtime/class_linker.cpp @@ -944,10 +944,13 @@ Class *ClassLinker::LoadArrayClass(const uint8_t *descriptor, bool need_copy_des return nullptr; } +#if defined(PANDA_TARGET_WINDOWS) && defined(VOID) +#undef VOID if (UNLIKELY(component_class->GetType().GetId() == panda_file::Type::TypeId::VOID)) { OnError(error_handler, Error::NO_CLASS_DEF, "Try to create array with void component type"); return nullptr; } +#endif auto *ext = GetExtension(component_class->GetSourceLang()); ASSERT(ext != nullptr); diff --git a/runtime/include/runtime.h b/runtime/include/runtime.h index a1c35cf3186c7aa0cf1b6c22a535d6666f005ad4..a697ce26d8b3cb55120f2eecfa6e5b7945a43fe6 100644 --- a/runtime/include/runtime.h +++ b/runtime/include/runtime.h @@ -24,7 +24,9 @@ #include "libpandabase/mem/arena_allocator.h" #include "libpandabase/os/mutex.h" +#ifndef PANDA_TARGET_WINDOWS #include "libpandabase/os/library_loader.h" +#endif #include "libpandabase/utils/expected.h" #include "libpandabase/utils/dfx.h" #include "libpandafile/file_items.h" @@ -34,7 +36,9 @@ #include "runtime/include/runtime_options.h" #include "runtime/include/gc_task.h" #include "runtime/include/tooling/debug_interface.h" +#ifdef PANDA_TARGET_UNIX #include "runtime/signal_handler.h" +#endif #include "runtime/mem/allocator_adapter.h" #include "runtime/mem/gc/gc.h" #include "runtime/mem/gc/gc_trigger.h" @@ -160,10 +164,12 @@ public: is_debug_mode_ = is_debug_mode; } +#ifndef PANDA_TARGET_WINDOWS void SetDebuggerLibrary(os::library_loader::LibraryHandle debugger_library) { debugger_library_ = std::move(debugger_library); } +#endif bool IsDebuggerConnected() const { @@ -307,12 +313,14 @@ public: return is_stacktrace_; } +#ifdef PANDA_TARGET_UNIX SignalManager *GetSignalManager() { return signal_manager_; } Trace *CreateTrace(LanguageContext ctx, PandaUniquePtr trace_file, size_t buffer_size); +#endif // PANDA_TARGET_UNIX void SetPtLangExt(tooling::PtLangExt *pt_lang_ext); @@ -377,7 +385,9 @@ private: PandaVM *panda_vm_ = nullptr; +#ifdef PANDA_TARGET_UNIX SignalManager *signal_manager_ {nullptr}; +#endif // Language context static constexpr size_t LANG_EXTENSIONS_COUNT = static_cast(panda_file::SourceLang::LAST) + 1; @@ -388,7 +398,9 @@ private: bool is_debugger_connected_ {false}; tooling::PtLangExt *pt_lang_ext_ {nullptr}; tooling::DebugInterface *debugger_ {nullptr}; +#ifndef PANDA_TARGET_WINDOWS os::library_loader::LibraryHandle debugger_library_; +#endif // Additional VMInfo std::string process_package_name_; diff --git a/runtime/mem/gc/crossing_map.cpp b/runtime/mem/gc/crossing_map.cpp index 46562e8e381adcf87c5c0c730740233c63ae9e3f..790579d4c12dc57ed765f220f0b4e38cca023097 100644 --- a/runtime/mem/gc/crossing_map.cpp +++ b/runtime/mem/gc/crossing_map.cpp @@ -14,6 +14,7 @@ */ #include "runtime/mem/gc/crossing_map.h" +#include "securec.h" #include diff --git a/runtime/mem/gc/gc.cpp b/runtime/mem/gc/gc.cpp index c1920af15c417130c55c40efc9e68a776a33bc27..0aa8af51537d56dcb8b376d21be490b2473900ba 100644 --- a/runtime/mem/gc/gc.cpp +++ b/runtime/mem/gc/gc.cpp @@ -398,7 +398,11 @@ void GC::CreateWorker() if (worker_ == nullptr) { LOG(FATAL, RUNTIME) << "Cannot create a GC thread"; } +#ifdef PANDA_TARGET_UNIX int res = os::thread::SetThreadName(worker_->native_handle(), "GCThread"); +#else + int res = os::thread::SetThreadName(worker_->get_id(), "GCThread"); +#endif if (res != 0) { LOG(ERROR, RUNTIME) << "Failed to set a name for the gc thread"; } diff --git a/runtime/mem/malloc-proxy-allocator-inl.h b/runtime/mem/malloc-proxy-allocator-inl.h index 57eb1df1b26cc3d929e2aa1c6216c1829db9effd..f5c8ae40a81766ba7f5aea3b3f34d097eea7d79d 100644 --- a/runtime/mem/malloc-proxy-allocator-inl.h +++ b/runtime/mem/malloc-proxy-allocator-inl.h @@ -48,7 +48,11 @@ void *MallocProxyAllocator::Alloc(size_t size, Alignment align) } size_t alignment_in_bytes = GetAlignmentInBytes(align); size_t aligned_size = (size + alignment_in_bytes - 1) & ~(alignment_in_bytes - 1); +#ifndef PANDA_TARGET_WINDOWS void *ret = aligned_alloc(alignment_in_bytes, aligned_size); +#else + void *ret = _aligned_malloc(aligned_size, alignment_in_bytes); +#endif // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) if constexpr (!DUMMY_ALLOC_CONFIG) { ASSERT(allocated_memory_.find(ret) == allocated_memory_.end()); diff --git a/runtime/mem/mem_hooks.cpp b/runtime/mem/mem_hooks.cpp index 0a0700045a5749acc823716ae4d11c8a2fcb930f..b78cf92fe77e981660e5754dfe47926528f0c96c 100644 --- a/runtime/mem/mem_hooks.cpp +++ b/runtime/mem/mem_hooks.cpp @@ -22,17 +22,21 @@ namespace panda::mem { size_t PandaHooks::alloc_via_standard = 0; +#ifndef PANDA_TARGET_WINDOWS void *(*volatile PandaHooks::old_malloc_hook)(size_t, const void *) = nullptr; void *(*volatile PandaHooks::old_memalign_hook)(size_t, size_t, const void *) = nullptr; void (*volatile PandaHooks::old_free_hook)(void *, const void *) = nullptr; +#endif // PANDA_TARGET_WINDOWS /* static */ void PandaHooks::SaveMemHooks() { #ifndef __MUSL__ +#ifndef PANDA_TARGET_WINDOWS old_malloc_hook = __malloc_hook; old_memalign_hook = __memalign_hook; old_free_hook = __free_hook; +#endif // PANDA_TARGET_WINDOWS #endif // __MUSL__ } @@ -40,9 +44,11 @@ void PandaHooks::SaveMemHooks() void PandaHooks::SetMemHooks() { #ifndef __MUSL__ +#ifndef PANDA_TARGET_WINDOWS __malloc_hook = MallocHook; __memalign_hook = MemalignHook; __free_hook = FreeHook; +#endif // PANDA_TARGET_WINDOWS #endif // __MUSL__ } @@ -67,6 +73,7 @@ void *PandaHooks::MallocHook(size_t size, [[maybe_unused]] const void *caller) return result; } +#ifndef PANDA_TARGET_WINDOWS /* static */ void *PandaHooks::MemalignHook(size_t alignment, size_t size, [[maybe_unused]] const void *caller) { @@ -87,6 +94,7 @@ void *PandaHooks::MemalignHook(size_t alignment, size_t size, [[maybe_unused]] c SetMemHooks(); return result; } +#endif // PANDA_TARGET_WINDOWS /* static */ void PandaHooks::FreeHook(void *ptr, [[maybe_unused]] const void *caller) @@ -108,9 +116,11 @@ void PandaHooks::Enable() void PandaHooks::Disable() { #ifndef __MUSL__ +#ifndef PANDA_TARGET_WINDOWS __malloc_hook = old_malloc_hook; __memalign_hook = old_memalign_hook; __free_hook = old_free_hook; +#endif // PANDA_TARGET_WINDOWS #endif // __MUSL__ } diff --git a/runtime/mem/mem_stats.h b/runtime/mem/mem_stats.h index 31b442140cb49ed480035a83a2ff2cf994b4610c..5c4a8c263d39a2573c1f6d96354f08f527ee330f 100644 --- a/runtime/mem/mem_stats.h +++ b/runtime/mem/mem_stats.h @@ -120,7 +120,7 @@ private: duration min_pause_ = duration(0); duration max_pause_ = duration(0); duration sum_pause_ = duration(0); - uint pause_count_ = 0; + uint64_t pause_count_ = 0; // make groups of different parts of the VM (JIT, interpreter, etc) std::atomic_uint64_t objects_allocated_ = 0; diff --git a/runtime/mem/mem_stats_additional_info.cpp b/runtime/mem/mem_stats_additional_info.cpp index e2f299007e32e3b9c29328fc7721c9933945f549..669eb70d0c1a01b391dca6b8c05a593434c0f36c 100644 --- a/runtime/mem/mem_stats_additional_info.cpp +++ b/runtime/mem/mem_stats_additional_info.cpp @@ -65,7 +65,7 @@ void MemStatsAdditionalInfo::RecordGCPhaseEnd() os::memory::LockHolder lk(phase_lock_); ASSERT(current_phase_ != GCPhase::GC_PHASE_LAST); - uint phase_index = ToIndex(current_phase_); + uint64_t phase_index = ToIndex(current_phase_); duration phase_time = clock::now() - phase_start_time_; if (phase_count_[phase_index] != 0) { min_phase_time_[phase_index] = std::min(min_phase_time_[phase_index], phase_time); diff --git a/runtime/mem/mem_stats_additional_info.h b/runtime/mem/mem_stats_additional_info.h index 6ed7b55554f085a6b19e375e51e4c814ad9578ee..4f9f7673838d4c97214efb8128784d27f45b7509 100644 --- a/runtime/mem/mem_stats_additional_info.h +++ b/runtime/mem/mem_stats_additional_info.h @@ -57,7 +57,7 @@ private: std::array min_phase_time_ = {}; std::array max_phase_time_ = {}; std::array sum_phase_time_ = {}; - std::array phase_count_ = {}; + std::array phase_count_ = {}; os::memory::Mutex phase_lock_; }; diff --git a/runtime/mem/refstorage/global_object_storage.h b/runtime/mem/refstorage/global_object_storage.h index 0162242cc8098ef6874d46b56e3ace74cdfbd2db..22badc6de6920e00bff28820008c052627a79e8c 100644 --- a/runtime/mem/refstorage/global_object_storage.h +++ b/runtime/mem/refstorage/global_object_storage.h @@ -335,8 +335,12 @@ private: void Dump() REQUIRES_SHARED(mutex_) { - if (DfxController::IsInitialized() && - DfxController::GetOptionValue(DfxOptionHandler::REFERENCE_DUMP) != 1) { + if (DfxController::IsInitialized()) { +#ifdef PANDA_TARGET_UNIX + if (DfxController::GetOptionValue(DfxOptionHandler::REFERENCE_DUMP) != 1) { + return; + } +#endif return; } static constexpr size_t DUMP_NUMS = 20; diff --git a/runtime/mem/refstorage/reference_storage.cpp b/runtime/mem/refstorage/reference_storage.cpp index 4e960817d41fd55cc7d9db5c812bf5baf9e280d2..282c570df261551c583cac9caa64da89c7e3a889 100644 --- a/runtime/mem/refstorage/reference_storage.cpp +++ b/runtime/mem/refstorage/reference_storage.cpp @@ -372,7 +372,12 @@ void ReferenceStorage::DumpLocalRefClasses() void ReferenceStorage::DumpLocalRef() { - if (DfxController::IsInitialized() && DfxController::GetOptionValue(DfxOptionHandler::REFERENCE_DUMP) != 1) { + if (DfxController::IsInitialized()) { +#ifdef PANDA_TARGET_UNIX + if (DfxController::GetOptionValue(DfxOptionHandler::REFERENCE_DUMP) != 1) { + return; + } +#endif return; } LOG(ERROR, RUNTIME) << "--- local reference storage dump ---"; diff --git a/runtime/mem/region_space.cpp b/runtime/mem/region_space.cpp index b80b7233ef44b347882c27b14676226cfcf7e5b9..19893737868b58bc5c663e0f463c90d5c2d6984b 100644 --- a/runtime/mem/region_space.cpp +++ b/runtime/mem/region_space.cpp @@ -14,6 +14,7 @@ */ #include "runtime/mem/region_space-inl.h" #include "runtime/mem/rem_set-inl.h" +#include "securec.h" namespace panda::mem { diff --git a/runtime/mem/runslots.cpp b/runtime/mem/runslots.cpp index 9a3398ae57716c77643590351924dabe9378f5b3..65274f1b204dc616a1e4e1fbbc6ebe73a07604f7 100644 --- a/runtime/mem/runslots.cpp +++ b/runtime/mem/runslots.cpp @@ -18,6 +18,7 @@ #include #include "runtime/include/object_header.h" +#include "securec.h" namespace panda::mem { diff --git a/runtime/profilesaver/profile_dump_info.cpp b/runtime/profilesaver/profile_dump_info.cpp index 9b70c7a644da9fc05fc1bb6ad9b042dfe6956a59..167d6fe2967ac16c88e008b0cef8d5c37e9d265b 100644 --- a/runtime/profilesaver/profile_dump_info.cpp +++ b/runtime/profilesaver/profile_dump_info.cpp @@ -17,7 +17,9 @@ #include #include +#ifndef PANDA_TARGET_WINDOWS #include +#endif #include #include @@ -517,7 +519,7 @@ bool ProfileDumpInfo::ProcessLine(SerializerBuffer &line_buffer, uint32_t method bool ProfileDumpInfo::MergeAndSave(const PandaString &filename, uint64_t *bytes_written, bool force) { // NB! we using READWRITE mode to leave the creation job to framework layer. - panda::os::unix::file::File myfile = panda::os::file::Open(filename, panda::os::file::Mode::READWRITE); + panda::os::file::File myfile = panda::os::file::Open(filename, panda::os::file::Mode::READWRITE); if (!myfile.IsValid()) { LOG(ERROR, RUNTIME) << "Cannot open the profile file" << filename; return false; diff --git a/runtime/runtime.cpp b/runtime/runtime.cpp index 95385690d55ed28628c573b2bcc6d615d8369b41..d37c78cb4be63cab4df8f521e2b3b9b57dcced45 100644 --- a/runtime/runtime.cpp +++ b/runtime/runtime.cpp @@ -26,7 +26,9 @@ #include "libpandabase/events/events.h" #include "libpandabase/mem/mem_config.h" #include "libpandabase/mem/pool_manager.h" +#ifndef PANDA_TARGET_WINDOWS #include "libpandabase/os/library_loader.h" +#endif #include "libpandabase/os/native_stack.h" #include "libpandabase/os/thread.h" #include "libpandabase/utils/arena_containers.h" @@ -381,7 +383,9 @@ Runtime::Runtime(const RuntimeOptions &options, mem::InternalAllocatorPtr intern // CODECHECK-NOLINTNEXTLINE(CPP_RULE_ID_SMARTPOINTER_INSTEADOF_ORIGINPOINTER) notification_manager_(new RuntimeNotificationManager(internal_allocator_)), // CODECHECK-NOLINTNEXTLINE(CPP_RULE_ID_SMARTPOINTER_INSTEADOF_ORIGINPOINTER) +#ifndef PANDA_TARGET_WINDOWS debugger_library_(nullptr), +#endif zygote_no_threads_(false) { Runtime::options_ = options; @@ -410,7 +414,9 @@ Runtime::Runtime(const RuntimeOptions &options, mem::InternalAllocatorPtr intern // CODECHECK-NOLINTNEXTLINE(CPP_RULE_ID_SMARTPOINTER_INSTEADOF_ORIGINPOINTER) class_linker_ = new ClassLinker(internal_allocator_, std::move(extensions)); // CODECHECK-NOLINTNEXTLINE(CPP_RULE_ID_SMARTPOINTER_INSTEADOF_ORIGINPOINTER) +#ifdef PANDA_TARGET_UNIX signal_manager_ = new SignalManager(internal_allocator_); +#endif if (IsEnableMemoryHooks()) { // libbfd (which is used to get debug info from elf files) does a lot of allocations. @@ -438,8 +444,10 @@ Runtime::~Runtime() } trace::ScopedTrace scoped_trace("Delete state"); +#ifdef PANDA_TARGET_UNIX signal_manager_->DeleteHandlersArray(); delete signal_manager_; +#endif delete class_linker_; if (dprofiler_ != nullptr) { internal_allocator_->Delete(dprofiler_); @@ -841,6 +849,7 @@ std::optional Runtime::CreateApplicationClassLinkerContext(std:: Expected Runtime::ExecutePandaFile(std::string_view filename, std::string_view entry_point, const std::vector &args) { +#ifdef PANDA_TARGET_UNIX if (options_.IsDistributedProfiling()) { // Create app name from path to executable file. std::string_view app_name = [](std::string_view path) -> std::string_view { @@ -849,6 +858,7 @@ Expected Runtime::ExecutePandaFile(std::string_view filenam }(filename); StartDProfiler(app_name); } +#endif auto ctx_err = CreateApplicationClassLinkerContext(filename, entry_point); if (ctx_err) { @@ -882,12 +892,15 @@ void Runtime::RegisterAppInfo(const PandaVector &code_paths, const return path.substr((pos == std::string_view::npos) ? 0 : (pos + 1)); }(profile_output_filename); +#ifdef PANDA_TARGET_UNIX StartDProfiler(app_name); +#endif // this is exactly the place where start the profile saver ProfileSaver::Start(profile_output_filename, code_paths, PandaString(app_name)); } +#ifdef PANDA_TARGET_UNIX int Runtime::StartDProfiler(std::string_view app_name) { if (dprofiler_ != nullptr) { @@ -898,9 +911,11 @@ int Runtime::StartDProfiler(std::string_view app_name) dprofiler_ = internal_allocator_->New(app_name, Runtime::GetCurrent()); return 0; } +#endif bool Runtime::StartDebugger(const std::string &library_path) { +#ifndef PANDA_TARGET_WINDOWS auto handle = os::library_loader::Load(library_path); if (!handle) { return true; @@ -933,6 +948,9 @@ bool Runtime::StartDebugger(const std::string &library_path) // Turn off stdout buffering in debug mode setvbuf(stdout, nullptr, _IONBF, 0); return true; +#else + return false; +#endif } bool Runtime::AttachDebugger() @@ -951,6 +969,7 @@ bool Runtime::AttachDebugger() bool Runtime::Shutdown() { +#ifndef PANDA_TARGET_WINDOWS if (IsDebugMode() && debugger_library_.IsValid()) { using StopDebugger = int (*)(); @@ -971,7 +990,7 @@ bool Runtime::Shutdown() if (debugger_ != nullptr) { internal_allocator_->Delete(debugger_); } - +#endif // PANDA_TARGET_WINDOWS return ManagedThread::Shutdown(); } @@ -1179,6 +1198,7 @@ bool Runtime::SaveProfileInfo() const return save_profiling_info_; } +#ifdef PANDA_TARGET_UNIX Trace *Runtime::CreateTrace([[maybe_unused]] LanguageContext ctx, [[maybe_unused]] PandaUniquePtr trace_file, [[maybe_unused]] size_t buffer_size) @@ -1186,4 +1206,6 @@ Trace *Runtime::CreateTrace([[maybe_unused]] LanguageContext ctx, LOG(FATAL, RUNTIME) << "Method tracing isn't supported at the moment!"; return nullptr; } +#endif + } // namespace panda diff --git a/runtime/thread.cpp b/runtime/thread.cpp index 689bb11be1e1828329ac46d6f7c454b0776286c2..5cfba062c7fd784abafd2d0294c816c6719316b4 100644 --- a/runtime/thread.cpp +++ b/runtime/thread.cpp @@ -30,6 +30,8 @@ #include "runtime/include/panda_vm.h" #include "runtime/mem/runslots_allocator-inl.h" +#include + namespace panda { using TaggedValue = coretypes::TaggedValue; using TaggedType = coretypes::TaggedType; @@ -453,7 +455,12 @@ bool MTManagedThread::Sleep(uint64_t ms) void ManagedThread::SetThreadPriority(int32_t prio) { ThreadId tid = GetId(); +#ifdef PANDA_TARGET_UNIX int res = os::thread::SetPriority(tid, prio); +#else + auto hthread = GetCurrentThread(); + int res = os::thread::SetPriority(hthread, prio); +#endif if (res == 0) { LOG(DEBUG, RUNTIME) << "Successfully changed priority for thread " << tid << " to " << prio; } else { @@ -463,8 +470,13 @@ void ManagedThread::SetThreadPriority(int32_t prio) uint32_t ManagedThread::GetThreadPriority() const { +#ifdef PANDA_TARGET_UNIX ThreadId tid = GetId(); return os::thread::GetPriority(tid); +#else + auto hthread = GetCurrentThread(); + return os::thread::GetPriority(hthread); +#endif } void MTManagedThread::UpdateGCRoots() diff --git a/runtime/thread_manager.cpp b/runtime/thread_manager.cpp index 587d0a0880f74f4527caddafd549df0b47055717..162835b206dddc3c88c4c792e9282ff8c18ae731 100644 --- a/runtime/thread_manager.cpp +++ b/runtime/thread_manager.cpp @@ -281,6 +281,7 @@ void ThreadManager::RegisterSensitiveThread() const void ThreadManager::DumpUnattachedThreads(std::ostream &os) { +#ifdef PANDA_TARGET_UNIX os::native_stack::DumpUnattachedThread dump; dump.InitKernelTidLists(); os::memory::LockHolder lock(thread_lock_); @@ -288,6 +289,7 @@ void ThreadManager::DumpUnattachedThreads(std::ostream &os) dump.AddTid(static_cast(thread->GetId())); } dump.Dump(os, Runtime::GetCurrent()->IsDumpNativeCrash(), nullptr); +#endif } MTManagedThread *ThreadManager::SuspendAndWaitThreadByInternalThreadId(uint32_t thread_id) diff --git a/runtime/thread_pool.h b/runtime/thread_pool.h index 921a71cc84f3185bc000222a4df7949bf781fdd5..318c95ee9f25062a67a0a6398faba2ba123dd81c 100644 --- a/runtime/thread_pool.h +++ b/runtime/thread_pool.h @@ -257,7 +257,11 @@ private: LOG(FATAL, RUNTIME) << "Cannot create a worker thread"; } if (thread_name_ != nullptr) { +#ifdef PANDA_TARGET_UNIX int res = os::thread::SetThreadName(worker->native_handle(), thread_name_); +#else + int res = os::thread::SetThreadName(worker->get_id(), thread_name_); +#endif if (res != 0) { LOG(ERROR, RUNTIME) << "Failed to set a name for the worker thread"; } diff --git a/verification/debug/config_load.cpp b/verification/debug/config_load.cpp index 2871db0dd3ee933b083e51b22b5db5de6fa03612..4ce3dc91d78f7d78a02f44fc890a80e472c4786a 100644 --- a/verification/debug/config_load.cpp +++ b/verification/debug/config_load.cpp @@ -25,9 +25,7 @@ #include "verification/debug/breakpoint/breakpoint_private.h" #include "verification/debug/allowlist/allowlist_private.h" -#if !PANDA_TARGET_WINDOWS #include "securec.h" -#endif #include "utils/logger.h" #include "libpandabase/os/file.h" diff --git a/verification/job_queue/job_queue.cpp b/verification/job_queue/job_queue.cpp index 077fca503c505bfa9fbf63a93d5fa86d2f0f4a6f..4eed26fa199550a6d92b2afca365065ebbaa1476 100644 --- a/verification/job_queue/job_queue.cpp +++ b/verification/job_queue/job_queue.cpp @@ -28,6 +28,7 @@ #include "libpandabase/os/thread.h" #include "macros.h" +#include namespace panda::verifier { @@ -123,7 +124,11 @@ void JobQueue::Stop(bool wait_queue_empty) void *retval = nullptr; for (size_t n = 0; n < num_verifier_threads; ++n) { +#ifdef PANDA_TARGET_UNIX os::thread::ThreadJoin((*verifier_thread_handle)[n], &retval); +#else + os::thread::ThreadJoin(reinterpret_cast((*verifier_thread_handle)[n]), &retval); +#endif } }