1 Star 0 Fork 960

王志豪1/ark_runtime_core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
panzhenyu.patch 30.97 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
diff --git a/BUILD.gn b/BUILD.gn
index f30ca7f..af0c685 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -24,6 +24,13 @@ group("ark_packages") {
}
}
+group("ark_packages_for_windows") {
+ deps = [
+ "//utils/native/base:utilsecurec",
+ "$ark_root/runtime:libarkruntime_static_for_windows(//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 ecf04b5..b448632 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 fa244bc..c88e46b 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 8479aad..60b0f44 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 7ed3705..ada99a3 100644
--- a/libpandabase/BUILD.gn
+++ b/libpandabase/BUILD.gn
@@ -121,7 +121,6 @@ ohos_shared_library("libarkbase") {
deps = libarkbase_deps
- output_extension = "so"
if (!is_standard_system) {
relative_install_dir = "ark"
}
diff --git a/libpandabase/os/mem.h b/libpandabase/os/mem.h
index 47451fb..2808d83 100644
--- a/libpandabase/os/mem.h
+++ b/libpandabase/os/mem.h
@@ -26,6 +26,7 @@
#ifdef PANDA_TARGET_UNIX
#include "unix/unix_mem.h"
#elif PANDA_TARGET_WINDOWS
+#pragma message("PANDA_TARGET_WINDOWS define works !!!!!!!!!!!!!")
#include "windows/windows_mem.h"
#else
#error "Unsupported target: please provide mmap API"
diff --git a/libpandabase/os/native_stack.h b/libpandabase/os/native_stack.h
index 536b252..af0d40c 100644
--- a/libpandabase/os/native_stack.h
+++ b/libpandabase/os/native_stack.h
@@ -25,7 +25,9 @@
namespace panda::os::native_stack {
+#ifndef PANDA_TARGET_WINDOWS
const auto g_PandaThreadSigmask = pthread_sigmask; // NOLINT(readability-identifier-naming)
+#endif
#if defined(PANDA_TARGET_UNIX)
using DumpUnattachedThread = panda::os::unix::native_stack::DumpUnattachedThread;
const auto DumpKernelStack = panda::os::unix::native_stack::DumpKernelStack; // NOLINT(readability-identifier-naming)
diff --git a/libpandabase/os/thread.h b/libpandabase/os/thread.h
index 05cb783..df797ac 100644
--- a/libpandabase/os/thread.h
+++ b/libpandabase/os/thread.h
@@ -108,7 +108,7 @@ static void *ProxyFunc(void *args)
template <typename Func, typename... Args>
native_handle_type ThreadStart(Func *func, Args... args)
{
- native_handle_type tid;
+ native_handle_type tid = nullptr;
auto args_tuple = std::make_tuple(func, std::move(args)...);
internal::SharedPtrStruct<decltype(args_tuple)> *ptr = nullptr;
{
@@ -121,9 +121,12 @@ native_handle_type ThreadStart(Func *func, Args... args)
ptr->this_ptr = shared_ptr;
// Leave scope to make sure that local shared_ptr is destroyed before thread creation.
}
+#ifndef PANDA_TARGET_WINDOWS
pthread_create(&tid, nullptr,
&internal::ProxyFunc<Func, decltype(args_tuple), std::tuple_size<decltype(args_tuple)>::value>,
static_cast<void *>(ptr));
+#else
+#endif
return tid;
}
diff --git a/libpandafile/BUILD.gn b/libpandafile/BUILD.gn
index ee9080e..3d7b88b 100644
--- a/libpandafile/BUILD.gn
+++ b/libpandafile/BUILD.gn
@@ -75,7 +75,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 8ef7797..6a0bfcd 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/libziparchive/BUILD.gn b/libziparchive/BUILD.gn
index b5108d0..fe701ed 100644
--- a/libziparchive/BUILD.gn
+++ b/libziparchive/BUILD.gn
@@ -49,7 +49,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 9f090f1..f46b5b1 100644
--- a/runtime/BUILD.gn
+++ b/runtime/BUILD.gn
@@ -253,10 +253,207 @@ ohos_static_library("libarkruntime_static") {
subsystem_name = "ark"
}
+ohos_static_library("libarkruntime_static_for_windows") {
+ sources = [
+ "arch/asm_support.cpp",
+ "assert_gc_scope.cpp",
+ "bridge/bridge.cpp",
+ "cframe.cpp",
+ "class.cpp",
+ "class_helper.cpp",
+ "class_initializer.cpp",
+ "class_linker.cpp",
+ "class_linker_extension.cpp",
+ "coretypes/array.cpp",
+ "coretypes/string.cpp",
+ "dprofiler/dprofiler.cpp",
+ "dyn_class_linker_extension.cpp",
+ "entrypoints/entrypoints.cpp",
+ "exceptions.cpp",
+ "field.cpp",
+ "file_manager.cpp",
+ "gc_task.cpp",
+ "handle_scope.cpp",
+ "imtable_builder.cpp",
+ "interpreter/interpreter.cpp",
+ "interpreter/runtime_interface.cpp",
+ "intrinsics.cpp",
+ "language_context.cpp",
+ "locks.cpp",
+ "mark_word.cpp",
+ "mem/allocator.cpp",
+ "mem/gc/bitmap.cpp",
+ "mem/gc/card_table.cpp",
+ "mem/gc/crossing_map.cpp",
+ "mem/gc/crossing_map_singleton.cpp",
+ "mem/gc/dynamic/gc_dynamic_impl.cpp",
+ "mem/gc/epsilon/epsilon.cpp",
+ "mem/gc/epsilon/epsilon_barrier.cpp",
+ "mem/gc/g1/g1-allocator.cpp",
+ "mem/gc/g1/g1-gc.cpp",
+ "mem/gc/gc.cpp",
+ "mem/gc/gc_barrier_set.cpp",
+ "mem/gc/gc_queue.cpp",
+ "mem/gc/gc_root.cpp",
+ "mem/gc/gc_scoped_phase.cpp",
+ "mem/gc/gc_stats.cpp",
+ "mem/gc/gc_trigger.cpp",
+ "mem/gc/gen-gc/gen-gc.cpp",
+ "mem/gc/generational-gc-base.cpp",
+ "mem/gc/hybrid-gc/hybrid_object_allocator.cpp",
+ "mem/gc/lang/gc_lang.cpp",
+ "mem/gc/reference-processor/reference_processor.cpp",
+ "mem/gc/static/gc_static_impl.cpp",
+ "mem/gc/stw-gc/stw-gc.cpp",
+ "mem/heap_manager.cpp",
+ "mem/heap_verifier.cpp",
+ "mem/internal_allocator.cpp",
+ "mem/mem_stats.cpp",
+ "mem/mem_stats_additional_info.cpp",
+ "mem/mem_stats_default.cpp",
+ "mem/memory_manager.cpp",
+ "mem/object_helpers.cpp",
+ "mem/panda_string.cpp",
+ "mem/refstorage/global_object_storage.cpp",
+ "mem/refstorage/ref_block.cpp",
+ "mem/refstorage/reference_storage.cpp",
+ "mem/region_space.cpp",
+ "mem/rendezvous.cpp",
+ "mem/runslots.cpp",
+ "mem/tlab.cpp",
+ "method.cpp",
+ "monitor.cpp",
+ "monitor_object_lock.cpp",
+ "monitor_pool.cpp",
+ "object_accessor.cpp",
+ "object_header.cpp",
+ "panda_vm.cpp",
+ "profilesaver/profile_saver.cpp",
+ "runtime.cpp",
+ "runtime_helpers.cpp",
+ "stack_walker.cpp",
+ "string_table.cpp",
+ "thread.cpp",
+ "thread_manager.cpp",
+ "time_utils.cpp",
+ "timing.cpp",
+ "tooling/debug_inf.cpp",
+ "tooling/debugger.cpp",
+ "tooling/pt_class.cpp",
+ "tooling/pt_lang_extension.cpp",
+ "tooling/pt_method.cpp",
+ "tooling/pt_reference.cpp",
+ "tooling/pt_thread.cpp",
+ "vtable_builder.cpp",
+ ]
+ if (current_cpu == "arm") {
+ sources += [
+ "arch/arm/interpreter_support.S",
+ "bridge/arch/arm/compiled_code_to_interpreter_bridge_arm.S",
+ "bridge/arch/arm/compiled_code_to_interpreter_bridge_dyn_arm.S",
+ "bridge/arch/arm/interpreter_to_compiled_code_bridge_arm.S",
+ "bridge/arch/arm/interpreter_to_compiled_code_bridge_dyn_arm.S",
+ ]
+ } else if (current_cpu == "arm64") {
+ sources += [
+ "arch/aarch64/interpreter_support.S",
+ "bridge/arch/aarch64/compiled_code_to_interpreter_bridge_aarch64.S",
+ "bridge/arch/aarch64/compiled_code_to_interpreter_bridge_dyn_aarch64.S",
+ "bridge/arch/aarch64/interpreter_to_compiled_code_bridge_aarch64.S",
+ "bridge/arch/aarch64/interpreter_to_compiled_code_bridge_dyn_aarch64.S",
+ ]
+ } else if (current_cpu == "x86") {
+ sources += [
+ "arch/x86/interpreter_support.S",
+ "bridge/arch/x86/compiled_code_to_interpreter_bridge_x86.S",
+ "bridge/arch/x86/interpreter_to_compiled_code_bridge_x86.S",
+ ]
+ } else if (current_cpu == "amd64" || current_cpu == "x64" ||
+ current_cpu == "x86_64") {
+ sources += [
+ "arch/amd64/interpreter_support.S",
+ "bridge/arch/amd64/compiled_code_to_interpreter_bridge_amd64.S",
+ "bridge/arch/amd64/compiled_code_to_interpreter_bridge_dyn_amd64.S",
+ "bridge/arch/amd64/interpreter_to_compiled_code_bridge_amd64.S",
+ "bridge/arch/amd64/interpreter_to_compiled_code_bridge_dyn_amd64.S",
+ ]
+ }
+
+ core_vm_sources = [
+ "core/core_class_linker_extension.cpp",
+ "core/core_language_context.cpp",
+ "core/core_vm.cpp",
+ ]
+
+ sources += core_vm_sources
+ sources += verifier_sources
+
+ configs = [
+ sdk_libc_secshared_config,
+ "$ark_root:ark_config",
+ "$ark_root/libpandabase:arkbase_public_config",
+ "$ark_root/libpandafile:arkfile_public_config",
+ "$ark_root/verification/gen:verification_public_config",
+ ":arkruntime_public_config",
+ ":arkruntime_config",
+ "$ark_root/runtime/asm_defines:asmdefines_public_config",
+ ]
+
+ print("happy current sdk_libc_secshared_dep: $sdk_libc_secshared_dep")
+ if (is_mingw) {
+ print("happy this is mingw")
+ } else if (is_mac) {
+ print("happy this is mac")
+ } else if (is_linux) {
+ print("happy this is linux")
+ }
+
+ deps = [
+ ":arkruntime_header_deps",
+ ":arkruntime_interpreter_impl",
+ "$ark_root/libpandabase:libarkbase",
+ "$ark_root/libpandafile:libarkfile",
+ "$ark_root/libpandafile:libarkfile_type_gen_h",
+ "$ark_root/libziparchive:libarkziparchive",
+ "$ark_root/runtime/asm_defines:asm_defines_generator",
+ "//utils/native/base:utilsecurec",
+ sdk_libc_secshared_dep,
+ ]
+
+ if (is_standard_system) {
+ cflags_cc = [ "-fvisibility=hidden" ]
+ }
+
+ if (current_cpu == "arm") {
+ deps += [
+ ":bridge_dispatch_arm",
+ ":bridge_dispatch_dyn_arm",
+ ]
+ } else if (current_cpu == "arm64") {
+ deps += [
+ ":bridge_dispatch_aarch64",
+ ":bridge_dispatch_dyn_aarch64",
+ ]
+ } else if (current_cpu == "amd64" || current_cpu == "x64" ||
+ current_cpu == "x86_64") {
+ deps += [
+ ":bridge_dispatch_amd64",
+ ":bridge_dispatch_dyn_amd64",
+ ]
+ }
+
+ if (current_cpu == "amd64" || current_cpu == "x64" ||
+ current_cpu == "x86_64") {
+ ldflags = [ "-latomic" ]
+ }
+
+ output_extension = "dll"
+ 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 bae94a8..85ebb21 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/bridge/arch/amd64/compiled_code_to_interpreter_bridge_amd64.S b/runtime/bridge/arch/amd64/compiled_code_to_interpreter_bridge_amd64.S
index 21d5a31..cb3bbea 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 f006991..1151797 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 273d7e8..5dbe27b 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)
@@ -65,7 +67,9 @@
#include "entrypoints_bridge_asm_macro.inl"
.global AbstractMethodStub
+#ifndef PANDA_TARGET_WINDOWS
.type AbstractMethodStub, %function
+#endif
AbstractMethodStub:
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 0090d82..d1106b8 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 6183b71..d71c334 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 df73d2b..91fe0f8 100644
--- a/runtime/class_linker.cpp
+++ b/runtime/class_linker.cpp
@@ -33,10 +33,12 @@
#include "libpandafile/class_data_accessor-inl.h"
#include "libpandafile/code_data_accessor-inl.h"
#include "libpandafile/field_data_accessor-inl.h"
+#include "libpandafile/file_items.h"
#include "libpandafile/method_data_accessor-inl.h"
#include "libpandafile/modifiers.h"
#include "libpandafile/panda_cache.h"
#include "libpandafile/proto_data_accessor-inl.h"
+#include "runtime/include/class_helper.h"
#include "runtime/include/tooling/debug_inf.h"
#include "trace/trace.h"
@@ -944,10 +946,12 @@ Class *ClassLinker::LoadArrayClass(const uint8_t *descriptor, bool need_copy_des
return nullptr;
}
+#ifndef PANDA_TARGET_WINDOWS
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 de02986..3a03544 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"
+#if !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"
+#if !PANDA_TARGET_WINDOWS
#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"
@@ -162,10 +166,12 @@ public:
is_debug_mode_ = is_debug_mode;
}
+#if !PANDA_TARGET_WINDOWS
void SetDebuggerLibrary(os::library_loader::LibraryHandle debugger_library)
{
debugger_library_ = std::move(debugger_library);
}
+#endif
bool IsDebuggerConnected() const
{
@@ -309,18 +315,22 @@ public:
return is_stacktrace_;
}
+#if !PANDA_TARGET_WINDOWS
SignalManager *GetSignalManager()
{
return signal_manager_;
}
Trace *CreateTrace(LanguageContext ctx, PandaUniquePtr<os::unix::file::File> trace_file, size_t buffer_size);
+#endif
void SetPtLangExt(tooling::PtLangExt *pt_lang_ext);
static mem::GCType GetGCType(const RuntimeOptions &options);
+#ifndef PANDA_TARGET_WINDOWS
bool AttachDebugger();
+#endif
mem::InternalAllocatorPtr GetInternalAllocator() const
{
@@ -353,7 +363,9 @@ private:
bool LoadBootPandaFiles(panda_file::File::OpenMode open_mode);
+#ifndef PANDA_TARGET_WINDOWS
bool StartDebugger(const std::string &library_path);
+#endif
bool IsEnableMemoryHooks() const;
@@ -379,7 +391,9 @@ private:
PandaVM *panda_vm_ = nullptr;
+#if !PANDA_TARGET_WINDOWS
SignalManager *signal_manager_ {nullptr};
+#endif
// Language context
static constexpr size_t LANG_EXTENSIONS_COUNT = static_cast<size_t>(panda_file::SourceLang::LAST) + 1;
@@ -390,7 +404,9 @@ private:
bool is_debugger_connected_ {false};
tooling::PtLangExt *pt_lang_ext_ {nullptr};
tooling::DebugInterface *debugger_ {nullptr};
+#if !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 46562e8..17bfd3f 100644
--- a/runtime/mem/gc/crossing_map.cpp
+++ b/runtime/mem/gc/crossing_map.cpp
@@ -16,6 +16,7 @@
#include "runtime/mem/gc/crossing_map.h"
#include <cstring>
+#include <securec.h>
namespace panda::mem {
diff --git a/runtime/mem/malloc-proxy-allocator-inl.h b/runtime/mem/malloc-proxy-allocator-inl.h
index 57eb1df..5f48209 100644
--- a/runtime/mem/malloc-proxy-allocator-inl.h
+++ b/runtime/mem/malloc-proxy-allocator-inl.h
@@ -48,7 +48,11 @@ void *MallocProxyAllocator<AllocConfigT>::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);
+#ifdef PANDA_TARGET_WINDOWS
+ void *ret = _aligned_malloc(alignment_in_bytes, aligned_size);
+#else
void *ret = aligned_alloc(alignment_in_bytes, aligned_size);
+#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_stats.h b/runtime/mem/mem_stats.h
index 31b4421..5c4a8c2 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 e2f2990..669eb70 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 6ed7b55..4f9f767 100644
--- a/runtime/mem/mem_stats_additional_info.h
+++ b/runtime/mem/mem_stats_additional_info.h
@@ -57,7 +57,7 @@ private:
std::array<duration, ToIndex(GCPhase::GC_PHASE_LAST)> min_phase_time_ = {};
std::array<duration, ToIndex(GCPhase::GC_PHASE_LAST)> max_phase_time_ = {};
std::array<duration, ToIndex(GCPhase::GC_PHASE_LAST)> sum_phase_time_ = {};
- std::array<uint, ToIndex(GCPhase::GC_PHASE_LAST)> phase_count_ = {};
+ std::array<uint64_t, ToIndex(GCPhase::GC_PHASE_LAST)> 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 0162242..989b552 100644
--- a/runtime/mem/refstorage/global_object_storage.h
+++ b/runtime/mem/refstorage/global_object_storage.h
@@ -335,10 +335,12 @@ private:
void Dump() REQUIRES_SHARED(mutex_)
{
+#ifdef PANDA_TARGET_UNIX
if (DfxController::IsInitialized() &&
DfxController::GetOptionValue(DfxOptionHandler::REFERENCE_DUMP) != 1) {
return;
}
+#endif // PANDA_TARGET_UNIX
static constexpr size_t DUMP_NUMS = 20;
size_t num = 0;
LOG(INFO, RUNTIME) << "Dump the last " << DUMP_NUMS << " global references info:";
diff --git a/runtime/mem/refstorage/reference_storage.cpp b/runtime/mem/refstorage/reference_storage.cpp
index 4e96081..f014c50 100644
--- a/runtime/mem/refstorage/reference_storage.cpp
+++ b/runtime/mem/refstorage/reference_storage.cpp
@@ -372,9 +372,11 @@ void ReferenceStorage::DumpLocalRefClasses()
void ReferenceStorage::DumpLocalRef()
{
+#ifdef PANDA_TARGET_UNIX
if (DfxController::IsInitialized() && DfxController::GetOptionValue(DfxOptionHandler::REFERENCE_DUMP) != 1) {
return;
}
+#endif // PANDA_TARGET_UNIX
LOG(ERROR, RUNTIME) << "--- local reference storage dump ---";
LOG(ERROR, RUNTIME) << "Local reference storage addr: " << &local_storage_;
LOG(ERROR, RUNTIME) << "Dump the last several local references info(max " << MAX_DUMP_LOCAL_NUMS << "):";
diff --git a/runtime/mem/region_space.h b/runtime/mem/region_space.h
index 0df56e4..d9dc191 100644
--- a/runtime/mem/region_space.h
+++ b/runtime/mem/region_space.h
@@ -18,6 +18,7 @@
#include <atomic>
#include <cstdint>
+#include <securec.h>
#include "libpandabase/utils/list.h"
#include "runtime/include/mem/panda_containers.h"
diff --git a/runtime/mem/runslots.cpp b/runtime/mem/runslots.cpp
index 9a3398a..471d17a 100644
--- a/runtime/mem/runslots.cpp
+++ b/runtime/mem/runslots.cpp
@@ -16,6 +16,7 @@
#include "runtime/mem/runslots.h"
#include <cstring>
+#include <securec.h>
#include "runtime/include/object_header.h"
diff --git a/runtime/profilesaver/profile_dump_info.cpp b/runtime/profilesaver/profile_dump_info.cpp
index 9b70c7a..1847dd9 100644
--- a/runtime/profilesaver/profile_dump_info.cpp
+++ b/runtime/profilesaver/profile_dump_info.cpp
@@ -17,7 +17,9 @@
#include <sys/file.h>
#include <sys/stat.h>
+#if !PANDA_TARGET_WINDOWS
#include <sys/uio.h>
+#endif // PANDA_TARGET_WINDOWS
#include <cerrno>
#include <climits>
diff --git a/runtime/runtime.cpp b/runtime/runtime.cpp
index e0e1a67..160ed66 100644
--- a/runtime/runtime.cpp
+++ b/runtime/runtime.cpp
@@ -26,7 +26,11 @@
#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"
+#else
+#include "runtime/mem/mem_hooks.h"
+#endif
#include "libpandabase/os/native_stack.h"
#include "libpandabase/os/thread.h"
#include "libpandabase/utils/arena_containers.h"
@@ -53,7 +57,6 @@
#include "runtime/mem/gc/stw-gc/stw-gc.h"
#include "runtime/mem/gc/crossing_map_singleton.h"
#include "runtime/mem/heap_manager.h"
-#include "runtime/mem/mem_hooks.h"
#include "runtime/mem/memory_manager.h"
#include "runtime/mem/internal_allocator-inl.h"
#include "runtime/core/core_class_linker_extension.h"
@@ -395,6 +398,59 @@ void Runtime::Abort(const char *message /* = nullptr */)
std::abort();
}
+#ifdef PANDA_TARGET_WINDOWS
+// CODECHECK-NOLINTNEXTLINE(C_RULE_ID_FUNCTION_SIZE)
+Runtime::Runtime(const RuntimeOptions &options, mem::InternalAllocatorPtr internal_allocator,
+ const std::vector<LanguageContextBase *> &ctxs)
+ // CODECHECK-NOLINTNEXTLINE(CPP_RULE_ID_SMARTPOINTER_INSTEADOF_ORIGINPOINTER)
+ : internal_allocator_(internal_allocator),
+ // CODECHECK-NOLINTNEXTLINE(CPP_RULE_ID_SMARTPOINTER_INSTEADOF_ORIGINPOINTER)
+ notification_manager_(new RuntimeNotificationManager(internal_allocator_)),
+ // CODECHECK-NOLINTNEXTLINE(CPP_RULE_ID_SMARTPOINTER_INSTEADOF_ORIGINPOINTER)
+ zygote_no_threads_(false)
+{
+ Runtime::options_ = options;
+ // ECMAScript doesn't use intrinsics
+ if (options_.GetRuntimeType() == "ecmascript") {
+ options_.SetShouldInitializeIntrinsics(false);
+ }
+
+ auto spaces = GetOptions().GetBootClassSpaces();
+
+ // Default core context
+ static CoreLanguageContext lcCore;
+ language_contexts_[static_cast<size_t>(lcCore.GetLanguage())] = &lcCore;
+
+ for (const auto &ctx : ctxs) {
+ language_contexts_[static_cast<size_t>(ctx->GetLanguage())] = ctx;
+ }
+
+ std::vector<std::unique_ptr<ClassLinkerExtension>> extensions;
+ extensions.reserve(spaces.size());
+
+ for (const auto &space : spaces) {
+ extensions.push_back(GetLanguageContext(space).CreateClassLinkerExtension());
+ }
+
+ // CODECHECK-NOLINTNEXTLINE(CPP_RULE_ID_SMARTPOINTER_INSTEADOF_ORIGINPOINTER)
+ class_linker_ = new ClassLinker(internal_allocator_, std::move(extensions));
+
+ if (IsEnableMemoryHooks()) {
+ // libbfd (which is used to get debug info from elf files) does a lot of allocations.
+ // Don't track allocations in this case.
+ if (!options_.IsSafepointBacktrace()) {
+ mem::PandaHooks::Enable();
+ }
+ }
+
+ save_profiling_info_ = false;
+
+ VerificationOptions_.Initialize(options_);
+ InitializeVerificationResultCache(options_);
+
+ is_zygote_ = options_.IsStartAsZygote();
+}
+#else
// CODECHECK-NOLINTNEXTLINE(C_RULE_ID_FUNCTION_SIZE)
Runtime::Runtime(const RuntimeOptions &options, mem::InternalAllocatorPtr internal_allocator,
const std::vector<LanguageContextBase *> &ctxs)
@@ -449,6 +505,7 @@ Runtime::Runtime(const RuntimeOptions &options, mem::InternalAllocatorPtr intern
is_zygote_ = options_.IsStartAsZygote();
}
+#endif
Runtime::~Runtime()
{
@@ -460,8 +517,11 @@ Runtime::~Runtime()
}
trace::ScopedTrace scoped_trace("Delete state");
+#ifndef PANDA_TARGET_WINDOWS
signal_manager_->DeleteHandlersArray();
delete signal_manager_;
+#endif
+
delete class_linker_;
if (dprofiler_ != nullptr) {
internal_allocator_->Delete(dprofiler_);
@@ -598,6 +658,7 @@ bool Runtime::InitializePandaVM()
return false;
}
+#ifndef PANDA_TARGET_WINDOWS
std::string debug_library_path = options_.GetDebuggerLibraryPath();
if (!debug_library_path.empty()) {
if (!StartDebugger(debug_library_path)) {
@@ -605,6 +666,7 @@ bool Runtime::InitializePandaVM()
return false;
}
}
+#endif
if (!panda_vm_->Initialize()) {
LOG(ERROR, RUNTIME) << "Failed to initialize panda vm";
@@ -920,6 +982,7 @@ int Runtime::StartDProfiler(std::string_view app_name)
return 0;
}
+#ifndef PANDA_TARGET_WINDOWS
bool Runtime::StartDebugger(const std::string &library_path)
{
auto handle = os::library_loader::Load(library_path);
@@ -969,9 +1032,11 @@ bool Runtime::AttachDebugger()
debugger_ = internal_allocator_->New<tooling::Debugger>(this);
return true;
}
+#endif
bool Runtime::Shutdown()
{
+#ifndef PANDA_TARGET_WINDOWS
if (IsDebugMode() && debugger_library_.IsValid()) {
using StopDebugger = int (*)();
@@ -992,6 +1057,7 @@ bool Runtime::Shutdown()
if (debugger_ != nullptr) {
internal_allocator_->Delete(debugger_);
}
+#endif
return ManagedThread::Shutdown();
}
@@ -1200,6 +1266,7 @@ bool Runtime::SaveProfileInfo() const
return save_profiling_info_;
}
+#ifndef PANDA_TARGET_WINDOWS
Trace *Runtime::CreateTrace([[maybe_unused]] LanguageContext ctx,
[[maybe_unused]] PandaUniquePtr<os::unix::file::File> trace_file,
[[maybe_unused]] size_t buffer_size)
@@ -1207,4 +1274,5 @@ 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/verification/debug/config_load.cpp b/verification/debug/config_load.cpp
index 2871db0..ee62aec 100644
--- a/verification/debug/config_load.cpp
+++ b/verification/debug/config_load.cpp
@@ -25,7 +25,7 @@
#include "verification/debug/breakpoint/breakpoint_private.h"
#include "verification/debug/allowlist/allowlist_private.h"
-#if !PANDA_TARGET_WINDOWS
+#ifdef PANDA_TARGET_WINDOWS
#include "securec.h"
#endif
#include "utils/logger.h"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wang-zhihao-1/ark_runtime_core.git
git@gitee.com:wang-zhihao-1/ark_runtime_core.git
wang-zhihao-1
ark_runtime_core
ark_runtime_core
master

搜索帮助