!2417 Make ark-engine adapt to ios-platform

Merge pull request !2417 from Gongyuhang/master
This commit is contained in:
openharmony_ci 2022-10-14 03:05:26 +00:00 committed by Gitee
commit 72411e7f32
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
16 changed files with 65 additions and 35 deletions

View File

@ -159,7 +159,7 @@ config("ark_jsruntime_public_config") {
]
defines = []
if (!is_mingw && !is_mac && target_os != "android") {
if (!is_mingw && !is_mac && target_os != "android" && target_os != "ios") {
defines += [
"ECMASCRIPT_SUPPORT_CPUPROFILER",
"ECMASCRIPT_SUPPORT_HEAPPROFILER",
@ -267,6 +267,11 @@ config("ark_jsruntime_common_config") {
"PANDA_TARGET_UNIX",
"PANDA_USE_FUTEX",
]
} else if (target_os == "ios") {
defines += [
"PANDA_TARGET_IOS",
"PANDA_TARGET_UNIX",
]
} else {
defines += [
"PANDA_TARGET_UNIX",
@ -277,7 +282,7 @@ config("ark_jsruntime_common_config") {
}
}
if (!defined(ark_standalone_build) && !is_mac) {
if (!defined(ark_standalone_build) && !is_mac && target_os != "ios") {
if (!use_libfuzzer) {
cflags_cc += [ "-flto" ]
ldflags = [ "-flto" ]
@ -611,7 +616,7 @@ ecma_source = [
"ecmascript/require/js_require_manager.cpp",
]
if (!is_mingw && !is_mac) {
if (!is_mingw && !is_mac && target_os != "ios") {
ecma_source += [ "ecmascript/napi/dfx_jsnapi.cpp" ]
ecma_source += [ "ecmascript/dfx/hprof/file_stream.cpp" ]
}
@ -628,7 +633,7 @@ ecma_debugger_source = [
]
ecma_profiler_source = []
if (!is_mingw && !is_mac) {
if (!is_mingw && !is_mac && target_os != "ios") {
ecma_profiler_source += [
"ecmascript/dfx/cpu_profiler/cpu_profiler.cpp",
"ecmascript/dfx/cpu_profiler/sampling_processor.cpp",
@ -717,10 +722,19 @@ source_set("libark_js_intl_set") {
deps = [
"$ark_root/libpandafile:arkfile_header_deps",
"$third_party_gn_path/icu/icu4c:shared_icui18n",
"$third_party_gn_path/icu/icu4c:shared_icuuc",
sdk_libc_secshared_dep,
]
if (target_os == "ios") {
deps += [
"$third_party_gn_path/icu/icu4c:static_icui18n",
"$third_party_gn_path/icu/icu4c:static_icuuc",
]
} else {
deps += [
"$third_party_gn_path/icu/icu4c:shared_icui18n",
"$third_party_gn_path/icu/icu4c:shared_icuuc",
]
}
}
source_set("libark_jsruntime_test_set") {
@ -738,7 +752,7 @@ source_set("libark_jsruntime_test_set") {
if ((current_cpu == "amd64" || current_cpu == "x64" ||
current_cpu == "x86_64" || current_cpu == "arm64") && !is_mingw &&
!is_mac) {
!is_mac && target_os != "ios") {
deps += [ "$js_root/ecmascript/compiler:libark_stub_set" ]
} else {
deps += [ "$js_root/ecmascript/compiler:libark_mock_stub_set" ]
@ -762,7 +776,7 @@ source_set("libark_jsruntime_test_set") {
]
}
ohos_shared_library("libark_jsruntime") {
source_set("libark_jsruntime_static") {
deps = [
":libark_js_intl_set",
":libark_jsruntime_set",
@ -771,7 +785,7 @@ ohos_shared_library("libark_jsruntime") {
if ((current_cpu == "amd64" || current_cpu == "x64" ||
current_cpu == "x86_64" || current_cpu == "arm64") && !is_mingw &&
!is_mac) {
!is_mac && target_os != "ios") {
deps += [ "$js_root/ecmascript/compiler:libark_stub_set" ]
} else {
deps += [ "$js_root/ecmascript/compiler:libark_mock_stub_set" ]
@ -780,6 +794,10 @@ ohos_shared_library("libark_jsruntime") {
if (target_os == "android") {
aosp_deps = [ "shared_library:liblog" ]
}
}
ohos_shared_library("libark_jsruntime") {
deps = [ ":libark_jsruntime_static" ]
if (is_ohos && is_standard_system) {
if (enable_dump_in_faultlog || enable_bytrace || enable_hitrace ||

View File

@ -67,10 +67,10 @@ using Address = uintptr_t;
#define STATIC_ASSERT_EQ_ARCH64(a, b)
#endif
#if defined(PANDA_TARGET_WINDOWS) || defined(PANDA_TARGET_MACOS)
#define WIN_OR_MAC_PLATFORM true
#if defined(PANDA_TARGET_WINDOWS) || defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
#define WIN_OR_MAC_OR_IOS_PLATFORM true
#else
#define WIN_OR_MAC_PLATFORM false
#define WIN_OR_MAC_OR_IOS_PLATFORM false
#endif
#define STATIC_ASSERT_EQ_ARCH(expect, valueArch32, valueArch64) \

View File

@ -33,10 +33,12 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshadow"
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include "ecmascript/mem/machine_code.h"

View File

@ -32,10 +32,12 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshadow"
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include "llvm/IR/Instructions.h"

View File

@ -34,7 +34,7 @@
#if defined(ECMASCRIPT_SUPPORT_CPUPROFILER)
#include "ecmascript/dfx/cpu_profiler/cpu_profiler.h"
#endif
#if !WIN_OR_MAC_PLATFORM
#if !WIN_OR_MAC_OR_IOS_PLATFORM
#include "ecmascript/dfx/hprof/heap_profiler.h"
#include "ecmascript/dfx/hprof/heap_profiler_interface.h"
#endif
@ -183,7 +183,7 @@ bool EcmaVM::Initialize()
globalEnv_ = globalEnv.GetTaggedValue();
Builtins builtins;
builtins.Initialize(globalEnv, thread_);
if (!WIN_OR_MAC_PLATFORM && options_.EnableSnapshotSerialize()) {
if (!WIN_OR_MAC_OR_IOS_PLATFORM && options_.EnableSnapshotSerialize()) {
const CString fileName = "builtins.snapshot";
Snapshot snapshot(this);
snapshot.SerializeBuiltins(fileName);
@ -191,7 +191,7 @@ bool EcmaVM::Initialize()
} else {
const CString fileName = "builtins.snapshot";
Snapshot snapshot(this);
if (!WIN_OR_MAC_PLATFORM) {
if (!WIN_OR_MAC_OR_IOS_PLATFORM) {
snapshot.Deserialize(SnapshotType::BUILTINS, fileName, true);
}
globalConst->InitSpecialForSnapshot();
@ -210,7 +210,7 @@ bool EcmaVM::Initialize()
tsManager_->Initialize();
quickFixManager_ = new QuickFixManager();
snapshotEnv_ = new SnapshotEnv(this);
if (!WIN_OR_MAC_PLATFORM) {
if (!WIN_OR_MAC_OR_IOS_PLATFORM) {
snapshotEnv_->Initialize();
}
fileLoader_ = new FileLoader(this);
@ -739,7 +739,7 @@ void EcmaVM::Iterate(const RootVisitor &v, const RootRangeVisitor &rv)
moduleManager_->Iterate(v);
tsManager_->Iterate(v);
fileLoader_->Iterate(v);
if (!WIN_OR_MAC_PLATFORM) {
if (!WIN_OR_MAC_OR_IOS_PLATFORM) {
snapshotEnv_->Iterate(v);
}
}
@ -776,7 +776,7 @@ void EcmaVM::LoadAOTFiles()
fileLoader_->LoadSnapshotFile(etsoFile);
}
#if !WIN_OR_MAC_PLATFORM
#if !WIN_OR_MAC_OR_IOS_PLATFORM
void EcmaVM::DeleteHeapProfile()
{
if (heapProfile_ == nullptr) {

View File

@ -319,7 +319,7 @@ void FileLoader::LoadAOTFile(const std::string &fileName)
void FileLoader::LoadSnapshotFile([[maybe_unused]] const std::string& filename)
{
Snapshot snapshot(vm_);
#if !defined(PANDA_TARGET_WINDOWS) && !defined(PANDA_TARGET_MACOS)
#if !WIN_OR_MAC_OR_IOS_PLATFORM
snapshot.Deserialize(SnapshotType::ETSO, filename.c_str());
#endif
}

View File

@ -22,7 +22,7 @@
#include "ecmascript/llvm_stackmap_parser.h"
#include "ecmascript/interpreter/frame_handler.h"
#if defined(PANDA_TARGET_UNIX) && !defined(PANDA_TARGET_MACOS)
#if defined(PANDA_TARGET_UNIX) && !defined(PANDA_TARGET_MACOS) && !defined(PANDA_TARGET_IOS)
#include <sys/ptrace.h>
#else
#define ptrace(PTRACE_PEEKTEXT, pid, addr, NULL) static_cast<long>(-1)

View File

@ -388,7 +388,7 @@ public:
bool EnableSnapshotDeserialize() const
{
if (WIN_OR_MAC_PLATFORM) {
if (WIN_OR_MAC_OR_IOS_PLATFORM) {
return false;
}

View File

@ -15,11 +15,14 @@
#include "ecmascript/js_serializer.h"
#ifndef PANDA_TARGET_MACOS
#include <malloc.h>
#else
#if defined(PANDA_TARGET_IOS)
#include <stdlib.h>
#elif defined(PANDA_TARGET_MACOS)
#include <sys/malloc.h>
#else
#include <malloc.h>
#endif
#include <vector>
#include "ecmascript/base/array_helper.h"

View File

@ -37,7 +37,7 @@
#include "ecmascript/ecma_string_table.h"
#include "ecmascript/runtime_call_id.h"
#if !defined(PANDA_TARGET_WINDOWS) && !defined(PANDA_TARGET_MACOS)
#if !defined(PANDA_TARGET_WINDOWS) && !defined(PANDA_TARGET_MACOS) && !defined(PANDA_TARGET_IOS)
#include <sys/sysinfo.h>
#endif

View File

@ -18,7 +18,7 @@
#if defined(PANDA_TARGET_WINDOWS)
#include <io.h>
#include <sysinfoapi.h>
#elif defined(PANDA_TARGET_MACOS)
#elif defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
#include "sys/sysctl.h"
#else
#include "sys/sysinfo.h"
@ -120,7 +120,7 @@ void MemMapAllocator::AdapterSuitablePoolCapacity()
status.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&status);
DWORDLONG physSize = status.ullTotalPhys;
#elif PANDA_TARGET_MACOS
#elif defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
static constexpr int MIB_LENGTH = 2;
int mib[2];
mib[0] = CTL_HW;

View File

@ -24,7 +24,7 @@
#include "libpandabase/os/mutex.h"
#if !(defined PANDA_TARGET_MACOS || defined PANDA_TARGET_WINDOWS)
#if !defined(PANDA_TARGET_MACOS) && !defined(PANDA_TARGET_WINDOWS) && !defined(PANDA_TARGET_IOS)
#include <sys/prctl.h>
#ifndef PR_SET_VMA
#define PR_SET_VMA 0x53564d41
@ -282,7 +282,7 @@ private:
void PageTag([[maybe_unused]]void *mem, [[maybe_unused]]size_t size, [[maybe_unused]]bool remove = false)
{
#if !(defined PANDA_TARGET_MACOS || defined PANDA_TARGET_WINDOWS)
#if !defined(PANDA_TARGET_MACOS) && !defined(PANDA_TARGET_WINDOWS) && !defined(PANDA_TARGET_IOS)
if (remove) {
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, mem, size, nullptr);
} else {

View File

@ -15,7 +15,7 @@
#include "ecmascript/mem/native_area_allocator.h"
#ifndef PANDA_TARGET_MACOS
#if !defined(PANDA_TARGET_MACOS) && !defined(PANDA_TARGET_IOS)
#include <malloc.h>
#else
#include <malloc/malloc.h>
@ -123,7 +123,7 @@ void NativeAreaAllocator::FreeBuffer(void *mem)
}
#if defined(PANDA_TARGET_WINDOWS)
DecreaseNativeMemoryUsage(_msize(mem));
#elif defined(PANDA_TARGET_MACOS)
#elif defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
DecreaseNativeMemoryUsage(malloc_size(mem));
#else
DecreaseNativeMemoryUsage(malloc_usable_size(mem));

View File

@ -164,8 +164,13 @@ EcmaVM *JSNApi::CreateJSVM(const RuntimeOption &option)
runtimeOptions.SetIsWorker(option.GetIsWorker());
// Mem
runtimeOptions.SetHeapSizeLimit(option.GetGcPoolSize());
// Disable the asm-interpreter of ark-engine for ios-platform temporarily.
#if !defined(PANDA_TARGET_IOS)
// asmInterpreter
runtimeOptions.SetEnableAsmInterpreter(option.GetEnableAsmInterpreter());
#else
runtimeOptions.SetEnableAsmInterpreter(false);
#endif
runtimeOptions.SetAsmOpcodeDisableRange(option.GetAsmOpcodeDisableRange());
// Dfx
@ -616,7 +621,7 @@ void JSNApi::InitializeIcuData(const JSRuntimeOptions &options)
{
std::string icuPath = options.GetIcuDataPath();
if (icuPath == "default") {
#if !WIN_OR_MAC_PLATFORM && !defined(PANDA_TARGET_LINUX)
#if !WIN_OR_MAC_OR_IOS_PLATFORM && !defined(PANDA_TARGET_LINUX)
SetHwIcuDirectory();
#endif
} else {

View File

@ -17,7 +17,7 @@
#if defined(PANDA_TARGET_WINDOWS)
#include <sysinfoapi.h>
#elif defined(PANDA_TARGET_MACOS)
#elif defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
#include "sys/sysctl.h"
#else
#include "sys/sysinfo.h"
@ -61,7 +61,7 @@ uint32_t Taskpool::TheMostSuitableThreadNum(uint32_t threadNum) const
SYSTEM_INFO info;
GetSystemInfo(&info);
uint32_t numOfCpuCore = info.dwNumberOfProcessors;
#elif PANDA_TARGET_MACOS
#elif defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
uint32_t numOfCpuCore = MAC_MAX_THREADS_NUM;
#else
uint32_t numOfCpuCore = static_cast<uint32_t>(get_nprocs() / 2);

View File

@ -23,7 +23,7 @@
#include "os/mutex.h"
namespace panda::ecmascript {
#ifdef PANDA_TARGET_MACOS
#if defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
static constexpr uint32_t MAC_MAX_THREADS_NUM = 5;
#endif
class Taskpool {