From e08c17670966af4436bec97ba5a6dd708d9c81b2 Mon Sep 17 00:00:00 2001 From: Molokanov Yaroslav Date: Thu, 20 Jul 2023 12:58:47 +0300 Subject: [PATCH] Enabling -fvisibility=hidden for arkruntime library Signed-off-by: Molokanov Yaroslav --- runtime/CMakeLists.txt | 14 ++++++---- runtime/base/string_helper.h | 2 +- runtime/ecma_string.h | 2 +- runtime/ecma_vm.h | 10 +++---- .../include/tooling/pt_ecmascript_extension.h | 4 +-- runtime/js_array.h | 16 ++++++----- runtime/js_object.h | 18 ++++++------ runtime/js_tagged_value.h | 2 +- runtime/js_thread.h | 8 +++--- runtime/object_factory.h | 28 ++++++++++--------- 10 files changed, 56 insertions(+), 48 deletions(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 43b13100b..44e62a1c9 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -182,7 +182,7 @@ set(ECMASCRIPT_SOURCES ${ECMA_SRC_DIR}/tooling/pt_ecmascript_extension.cpp ) -add_dependencies(arkruntime_static ecmastdlib_inline_h) +add_dependencies(arkruntime_obj ecmastdlib_inline_h) set(IRTOC_ECMASCRIPT_SCRIPTS ${PANDA_ROOT}/plugins/ecmascript/irtoc_scripts) set(IRTOC_ECMASCRIPT_SCRIPTS ${IRTOC_ECMASCRIPT_SCRIPTS} PARENT_SCOPE) @@ -213,19 +213,21 @@ else() set(irtoc_ecmascript_fastpath_target panda_host_tools-build) endif() -add_dependencies(arkruntime_static +add_dependencies(arkruntime_obj ${irtoc_ecmascript_fastpath_target} ) -panda_target_sources(arkruntime_static PRIVATE ${ECMASCRIPT_SOURCES} ${IRTOC_ECMASCRIPT_FASTPATH_OBJ}) -panda_target_include_directories(arkruntime_static PUBLIC +panda_target_sources(arkruntime_obj PRIVATE ${ECMASCRIPT_SOURCES}) +panda_target_sources(arkruntime_interpreter_static PRIVATE ${IRTOC_ECMASCRIPT_FASTPATH_OBJ}) +panda_target_sources(arkruntime_static PRIVATE ${IRTOC_ECMASCRIPT_FASTPATH_OBJ}) +panda_target_include_directories(arkruntime_obj PUBLIC ${PANDA_ECMASCRIPT_PLUGIN_SOURCE}/runtime ${PANDA_BINARY_ROOT}/compiler/generated ${PANDA_BINARY_ROOT}/plugins/ecmascript/ecmastdlib ${ECMA_GEN_DIR} ) -panda_target_link_libraries(arkruntime_static es2panda-lib arkassembler) +panda_target_link_libraries(arkruntime_obj es2panda-lib arkassembler) set(RUNTIME_TEMPLATES intrinsics_gen.cpp.erb @@ -242,7 +244,7 @@ panda_gen( DESTINATION ${ECMA_GEN_DIR} ) -add_dependencies(arkruntime_static ecma_intrinsics_gen_arkruntime) +add_dependencies(arkruntime_obj ecma_intrinsics_gen_arkruntime) add_dependencies(intrinsics_gen_arkruntime ecma_intrinsics_gen_arkruntime) panda_target_include_directories(arkruntime_interpreter_impl PUBLIC diff --git a/runtime/base/string_helper.h b/runtime/base/string_helper.h index acf496839..e611189b3 100644 --- a/runtime/base/string_helper.h +++ b/runtime/base/string_helper.h @@ -53,7 +53,7 @@ enum TrimKind { TRIM_START, TRIM_END, TRIM_START_END }; class StringHelper { public: static constexpr int INVALID_UNICODE_FROM_UTF8 = -1; - static std::string ToStdString(EcmaString *string); + PANDA_PUBLIC_API static std::string ToStdString(EcmaString *string); static bool CheckDuplicate(EcmaString *string); diff --git a/runtime/ecma_string.h b/runtime/ecma_string.h index 0eaa63d2c..071722ce2 100644 --- a/runtime/ecma_string.h +++ b/runtime/ecma_string.h @@ -74,7 +74,7 @@ public: template uint16_t At(int32_t index) const; - int32_t Compare(const EcmaString *rhs) const; + PANDA_PUBLIC_API int32_t Compare(const EcmaString *rhs) const; bool IsUtf16() const { diff --git a/runtime/ecma_vm.h b/runtime/ecma_vm.h index c7a4ce317..199c6c8b5 100644 --- a/runtime/ecma_vm.h +++ b/runtime/ecma_vm.h @@ -93,9 +93,9 @@ public: return reinterpret_cast(object); } - static EcmaVM *Create(const JSRuntimeOptions &options); + PANDA_PUBLIC_API static EcmaVM *Create(const JSRuntimeOptions &options); - static bool Destroy(PandaVM *vm); + PANDA_PUBLIC_API static bool Destroy(PandaVM *vm); explicit EcmaVM(JSRuntimeOptions options); @@ -141,7 +141,7 @@ public: { mm_->InitializeGC(this); } - void StartGC() override + PANDA_PUBLIC_API void StartGC() override { mm_->StartGC(); } @@ -287,7 +287,7 @@ public: return options_; } - JSHandle GetGlobalEnv() const; + PANDA_PUBLIC_API JSHandle GetGlobalEnv() const; JSHandle GetMicroJobQueue() const; @@ -299,7 +299,7 @@ public: return reg_exp_parser_cache_; } - JSMethod *GetMethodForNativeFunction(const void *func); + PANDA_PUBLIC_API JSMethod *GetMethodForNativeFunction(const void *func); EcmaStringTable *GetEcmaStringTable() const { diff --git a/runtime/include/tooling/pt_ecmascript_extension.h b/runtime/include/tooling/pt_ecmascript_extension.h index 582f59f5a..0e9d8148c 100644 --- a/runtime/include/tooling/pt_ecmascript_extension.h +++ b/runtime/include/tooling/pt_ecmascript_extension.h @@ -24,8 +24,8 @@ namespace panda::tooling::ecmascript { using JSTaggedValue = panda::ecmascript::JSTaggedValue; class PtEcmaScriptExtension { public: - static VRegValue TaggedValueToVRegValue(JSTaggedValue value); - static JSTaggedValue VRegValueToTaggedValue(VRegValue value); + PANDA_PUBLIC_API static VRegValue TaggedValueToVRegValue(JSTaggedValue value); + PANDA_PUBLIC_API static JSTaggedValue VRegValueToTaggedValue(VRegValue value); }; } // namespace panda::tooling::ecmascript diff --git a/runtime/js_array.h b/runtime/js_array.h index bf71b5de0..80f651fa0 100644 --- a/runtime/js_array.h +++ b/runtime/js_array.h @@ -30,28 +30,30 @@ public: CAST_CHECK(JSArray, IsJSArray); - static JSHandle ArrayCreate(JSThread *thread, JSTaggedNumber length, - panda::SpaceType space_type = panda::SpaceType::SPACE_TYPE_OBJECT); + PANDA_PUBLIC_API static JSHandle ArrayCreate( + JSThread *thread, JSTaggedNumber length, panda::SpaceType space_type = panda::SpaceType::SPACE_TYPE_OBJECT); static JSHandle ArrayCreate(JSThread *thread, JSTaggedNumber length, const JSHandle &new_target, panda::SpaceType space_type = panda::SpaceType::SPACE_TYPE_OBJECT); static JSTaggedValue ArraySpeciesCreate(JSThread *thread, const JSHandle &original_array, JSTaggedNumber length); static bool ArraySetLength(JSThread *thread, const JSHandle &array, const PropertyDescriptor &desc); - static bool DefineOwnProperty(JSThread *thread, const JSHandle &array, const JSHandle &key, - const PropertyDescriptor &desc); + PANDA_PUBLIC_API static bool DefineOwnProperty(JSThread *thread, const JSHandle &array, + const JSHandle &key, const PropertyDescriptor &desc); static bool DefineOwnProperty(JSThread *thread, const JSHandle &array, uint32_t index, const PropertyDescriptor &desc); static bool IsLengthString(JSThread *thread, const JSHandle &key); // ecma6 7.3 Operations on Objects - static JSHandle CreateArrayFromList(JSThread *thread, const JSHandle &elements) + PANDA_PUBLIC_API static JSHandle CreateArrayFromList(JSThread *thread, + const JSHandle &elements) { return CreateArrayFromList(thread, elements, elements->GetLength()); } - static JSHandle CreateArrayFromList(JSThread *thread, const JSHandle &elements, - ArraySizeT length); + PANDA_PUBLIC_API static JSHandle CreateArrayFromList(JSThread *thread, + const JSHandle &elements, + ArraySizeT length); // use first inlined property slot for array length inline uint32_t GetArrayLength() const { diff --git a/runtime/js_object.h b/runtime/js_object.h index 0c81d8afe..92a11e620 100644 --- a/runtime/js_object.h +++ b/runtime/js_object.h @@ -427,8 +427,8 @@ public: static bool PreventExtensions(JSThread *thread, const JSHandle &obj); // [[GetOwnProperty]] -> Undefined | Property Descriptor - static bool GetOwnProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key, - PropertyDescriptor &desc); + PANDA_PUBLIC_API static bool GetOwnProperty(JSThread *thread, const JSHandle &obj, + const JSHandle &key, PropertyDescriptor &desc); static bool GlobalGetOwnProperty(JSThread *thread, const JSHandle &key, PropertyDescriptor &desc); @@ -454,8 +454,8 @@ public: static bool ValidateAndApplyPropertyDescriptor(ObjectOperator *op, bool extensible, const PropertyDescriptor &desc, const PropertyDescriptor ¤t); - static OperationResult GetProperty(JSThread *thread, const JSHandle &obj, - const JSHandle &key); + PANDA_PUBLIC_API static OperationResult GetProperty(JSThread *thread, const JSHandle &obj, + const JSHandle &key); static OperationResult GetProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key, const JSHandle &receiver); @@ -470,8 +470,9 @@ public: static bool SetProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key, const JSHandle &value, bool may_throw = false); - static bool SetProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key, - const JSHandle &value, bool may_throw = false); + PANDA_PUBLIC_API static bool SetProperty(JSThread *thread, const JSHandle &obj, + const JSHandle &key, const JSHandle &value, + bool may_throw = false); static bool SetProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key, const JSHandle &value, const JSHandle &receiver, @@ -484,9 +485,10 @@ public: const JSHandle &value, bool may_throw); // [[HasProperty]] - static bool HasProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key); + PANDA_PUBLIC_API static bool HasProperty(JSThread *thread, const JSHandle &obj, + const JSHandle &key); - static bool HasProperty(JSThread *thread, const JSHandle &obj, uint32_t index); + PANDA_PUBLIC_API static bool HasProperty(JSThread *thread, const JSHandle &obj, uint32_t index); // 9.1.10 [[Delete]] static bool DeleteProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key); diff --git a/runtime/js_tagged_value.h b/runtime/js_tagged_value.h index 51ad60d0a..768240e9f 100644 --- a/runtime/js_tagged_value.h +++ b/runtime/js_tagged_value.h @@ -50,7 +50,7 @@ enum class ComparisonResult { using JSTaggedType = coretypes::TaggedType; -class JSTaggedValue : public coretypes::TaggedValue { +class PANDA_PUBLIC_API JSTaggedValue : public coretypes::TaggedValue { public: static JSTaggedValue Cast(ObjectHeader *object) { diff --git a/runtime/js_thread.h b/runtime/js_thread.h index 387bd2d63..fb844c5e0 100644 --- a/runtime/js_thread.h +++ b/runtime/js_thread.h @@ -73,7 +73,7 @@ public: ~JSThread() override; - EcmaVM *GetEcmaVM() const; + PANDA_PUBLIC_API EcmaVM *GetEcmaVM() const; static JSThread *Create(Runtime *runtime, PandaVM *vm); @@ -89,8 +89,8 @@ public: void Iterate(const RootVisitor &v0, const RootRangeVisitor &v1); - uintptr_t *ExpandHandleStorage(); - void ShrinkHandleStorage(int prev_index); + PANDA_PUBLIC_API uintptr_t *ExpandHandleStorage(); + PANDA_PUBLIC_API void ShrinkHandleStorage(int prev_index); JSTaggedType *GetHandleScopeStorageNext() const { @@ -139,7 +139,7 @@ public: return !JSTaggedValue(ManagedThread::GetException()).IsHole(); } - void ClearException(); + PANDA_PUBLIC_API void ClearException(); EcmaGlobalStorage *GetEcmaGlobalStorage() const { diff --git a/runtime/object_factory.h b/runtime/object_factory.h index fcf732f4e..9982574ad 100644 --- a/runtime/object_factory.h +++ b/runtime/object_factory.h @@ -135,8 +135,9 @@ public: // use for others create, prototype is Function.prototype // use for native function - JSHandle NewJSFunction(const JSHandle &env, const void *native_func = nullptr, - FunctionKind kind = FunctionKind::NORMAL_FUNCTION); + PANDA_PUBLIC_API JSHandle NewJSFunction(const JSHandle &env, + const void *native_func = nullptr, + FunctionKind kind = FunctionKind::NORMAL_FUNCTION); // use for method JSHandle NewJSFunction(const JSHandle &env, JSMethod *method, FunctionKind kind = FunctionKind::NORMAL_FUNCTION); @@ -237,7 +238,8 @@ public: JSHandle NewJSString(const JSHandle &str); - JSHandle NewTaggedArray(uint32_t length, JSTaggedValue init_val = JSTaggedValue::Hole()); + PANDA_PUBLIC_API JSHandle NewTaggedArray(uint32_t length, + JSTaggedValue init_val = JSTaggedValue::Hole()); JSHandle NewTaggedArray(uint32_t length, JSTaggedValue init_val, panda::SpaceType space_type); JSHandle NewWeakTaggedArray(uint32_t length, JSTaggedValue init_val = JSTaggedValue::Hole()); @@ -359,32 +361,32 @@ public: } // used for creating jsobject by constructor - JSHandle NewJSObjectByConstructor(const JSHandle &constructor, - const JSHandle &new_target, - panda::SpaceType space_type = panda::SpaceType::SPACE_TYPE_OBJECT); + PANDA_PUBLIC_API JSHandle NewJSObjectByConstructor( + const JSHandle &constructor, const JSHandle &new_target, + panda::SpaceType space_type = panda::SpaceType::SPACE_TYPE_OBJECT); JSHandle NewClassInfoExtractor(JSMethod *ctor_method); ~ObjectFactory() = default; // ----------------------------------- new string ---------------------------------------- - JSHandle NewFromString(const PandaString &data); - JSHandle NewFromCanBeCompressString(const PandaString &data); + PANDA_PUBLIC_API JSHandle NewFromString(const PandaString &data); + PANDA_PUBLIC_API JSHandle NewFromCanBeCompressString(const PandaString &data); - JSHandle NewFromStdString(const std::string &data); + PANDA_PUBLIC_API JSHandle NewFromStdString(const std::string &data); JSHandle NewFromStdStringUnCheck(const std::string &data, bool can_be_compress, panda::SpaceType space_type = panda::SpaceType::SPACE_TYPE_OBJECT); - JSHandle NewFromUtf8(const uint8_t *utf8_data, uint32_t utf8_len); + PANDA_PUBLIC_API JSHandle NewFromUtf8(const uint8_t *utf8_data, uint32_t utf8_len); JSHandle NewFromUtf8UnCheck(const uint8_t *utf8_data, uint32_t utf8_len, bool can_be_compress); - JSHandle NewFromUtf16(const uint16_t *utf16_data, uint32_t utf16_len); + PANDA_PUBLIC_API JSHandle NewFromUtf16(const uint16_t *utf16_data, uint32_t utf16_len); JSHandle NewFromUtf16UnCheck(const uint16_t *utf16_data, uint32_t utf16_len, bool can_be_compress); - JSHandle NewFromUtf8Literal(const uint8_t *utf8_data, uint32_t utf8_len); + PANDA_PUBLIC_API JSHandle NewFromUtf8Literal(const uint8_t *utf8_data, uint32_t utf8_len); JSHandle NewFromUtf8LiteralUnCheck(const uint8_t *utf8_data, uint32_t utf8_len, bool can_be_compress); - JSHandle NewFromUtf16Literal(const uint16_t *utf16_data, uint32_t utf16_len); + PANDA_PUBLIC_API JSHandle NewFromUtf16Literal(const uint16_t *utf16_data, uint32_t utf16_len); JSHandle NewFromUtf16LiteralUnCheck(const uint16_t *utf16_data, uint32_t utf16_len, bool can_be_compress); -- Gitee