mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
modify napi performance
1. add env in JSNativePointer deleter 2. delete new NativeObjectInfo 3. delete NapiNativeCallbackInfo, use ark stackinfo instead https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I9IDMS Signed-off-by: wengchangcheng <wengchangcheng@huawei.com> Change-Id: I1acf0e9f26096319ef74ef20e108ac63c9c2c21c
This commit is contained in:
parent
c90a67a7dc
commit
38db6db8ad
@ -208,7 +208,7 @@ EcmaContext::~EcmaContext()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// clear icu cache
|
// clear icu cache
|
||||||
ClearIcuCache();
|
ClearIcuCache(thread_);
|
||||||
|
|
||||||
if (runtimeStat_ != nullptr) {
|
if (runtimeStat_ != nullptr) {
|
||||||
vm_->GetChunk()->Delete(runtimeStat_);
|
vm_->GetChunk()->Delete(runtimeStat_);
|
||||||
|
@ -91,7 +91,6 @@ using HostPromiseRejectionTracker = void (*)(const EcmaVM* vm,
|
|||||||
PromiseRejectionEvent operation,
|
PromiseRejectionEvent operation,
|
||||||
void* data);
|
void* data);
|
||||||
using PromiseRejectCallback = void (*)(void* info);
|
using PromiseRejectCallback = void (*)(void* info);
|
||||||
using IcuDeleteEntry = void(*)(void *pointer, void *data);
|
|
||||||
class EcmaContext {
|
class EcmaContext {
|
||||||
public:
|
public:
|
||||||
static EcmaContext *CreateAndInitialize(JSThread *thread);
|
static EcmaContext *CreateAndInitialize(JSThread *thread);
|
||||||
@ -304,7 +303,7 @@ public:
|
|||||||
|
|
||||||
// For icu objects cache
|
// For icu objects cache
|
||||||
void SetIcuFormatterToCache(IcuFormatterType type, const std::string &locale, void *icuObj,
|
void SetIcuFormatterToCache(IcuFormatterType type, const std::string &locale, void *icuObj,
|
||||||
IcuDeleteEntry deleteEntry = nullptr)
|
NativePointerCallback deleteEntry = nullptr)
|
||||||
{
|
{
|
||||||
EcmaContext::IcuFormatter icuFormatter = IcuFormatter(locale, icuObj, deleteEntry);
|
EcmaContext::IcuFormatter icuFormatter = IcuFormatter(locale, icuObj, deleteEntry);
|
||||||
icuObjCache_[static_cast<int>(type)] = icuFormatter;
|
icuObjCache_[static_cast<int>(type)] = icuFormatter;
|
||||||
@ -319,13 +318,13 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearIcuCache()
|
void ClearIcuCache(JSThread *thread)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < static_cast<uint32_t>(IcuFormatterType::ICU_FORMATTER_TYPE_COUNT); i++) {
|
for (uint32_t i = 0; i < static_cast<uint32_t>(IcuFormatterType::ICU_FORMATTER_TYPE_COUNT); i++) {
|
||||||
auto &icuFormatter = icuObjCache_[i];
|
auto &icuFormatter = icuObjCache_[i];
|
||||||
IcuDeleteEntry deleteEntry = icuFormatter.deleteEntry;
|
NativePointerCallback deleteEntry = icuFormatter.deleteEntry;
|
||||||
if (deleteEntry != nullptr) {
|
if (deleteEntry != nullptr) {
|
||||||
deleteEntry(icuFormatter.icuObj, vm_);
|
deleteEntry(thread->GetEnv(), icuFormatter.icuObj, vm_);
|
||||||
}
|
}
|
||||||
icuFormatter = EcmaContext::IcuFormatter{};
|
icuFormatter = EcmaContext::IcuFormatter{};
|
||||||
}
|
}
|
||||||
@ -584,10 +583,10 @@ private:
|
|||||||
struct IcuFormatter {
|
struct IcuFormatter {
|
||||||
std::string locale;
|
std::string locale;
|
||||||
void *icuObj {nullptr};
|
void *icuObj {nullptr};
|
||||||
IcuDeleteEntry deleteEntry {nullptr};
|
NativePointerCallback deleteEntry {nullptr};
|
||||||
|
|
||||||
IcuFormatter() = default;
|
IcuFormatter() = default;
|
||||||
IcuFormatter(const std::string &locale, void *icuObj, IcuDeleteEntry deleteEntry = nullptr)
|
IcuFormatter(const std::string &locale, void *icuObj, NativePointerCallback deleteEntry = nullptr)
|
||||||
: locale(locale), icuObj(icuObj), deleteEntry(deleteEntry) {}
|
: locale(locale), icuObj(icuObj), deleteEntry(deleteEntry) {}
|
||||||
};
|
};
|
||||||
IcuFormatter icuObjCache_[static_cast<uint32_t>(IcuFormatterType::ICU_FORMATTER_TYPE_COUNT)];
|
IcuFormatter icuObjCache_[static_cast<uint32_t>(IcuFormatterType::ICU_FORMATTER_TYPE_COUNT)];
|
||||||
|
@ -526,7 +526,7 @@ void EcmaVM::ProcessNativeDelete(const WeakRootVisitor &visitor)
|
|||||||
auto fwd = visitor(reinterpret_cast<TaggedObject *>(object));
|
auto fwd = visitor(reinterpret_cast<TaggedObject *>(object));
|
||||||
if (fwd == nullptr) {
|
if (fwd == nullptr) {
|
||||||
nativeAreaAllocator_->DecreaseNativeSizeStats(object->GetBindingSize(), object->GetNativeFlag());
|
nativeAreaAllocator_->DecreaseNativeSizeStats(object->GetBindingSize(), object->GetNativeFlag());
|
||||||
object->Destroy();
|
object->Destroy(thread_);
|
||||||
iter = nativePointerList_.erase(iter);
|
iter = nativePointerList_.erase(iter);
|
||||||
} else {
|
} else {
|
||||||
++iter;
|
++iter;
|
||||||
@ -581,7 +581,7 @@ void EcmaVM::ProcessReferences(const WeakRootVisitor &visitor)
|
|||||||
auto fwd = visitor(reinterpret_cast<TaggedObject *>(object));
|
auto fwd = visitor(reinterpret_cast<TaggedObject *>(object));
|
||||||
if (fwd == nullptr) {
|
if (fwd == nullptr) {
|
||||||
nativeAreaAllocator_->DecreaseNativeSizeStats(object->GetBindingSize(), object->GetNativeFlag());
|
nativeAreaAllocator_->DecreaseNativeSizeStats(object->GetBindingSize(), object->GetNativeFlag());
|
||||||
object->Destroy();
|
object->Destroy(thread_);
|
||||||
iter = nativePointerList_.erase(iter);
|
iter = nativePointerList_.erase(iter);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -636,14 +636,14 @@ void EcmaVM::RemoveFromNativePointerList(JSNativePointer *pointer)
|
|||||||
if (iter != nativePointerList_.end()) {
|
if (iter != nativePointerList_.end()) {
|
||||||
JSNativePointer *object = *iter;
|
JSNativePointer *object = *iter;
|
||||||
nativeAreaAllocator_->DecreaseNativeSizeStats(object->GetBindingSize(), object->GetNativeFlag());
|
nativeAreaAllocator_->DecreaseNativeSizeStats(object->GetBindingSize(), object->GetNativeFlag());
|
||||||
object->Destroy();
|
object->Destroy(thread_);
|
||||||
nativePointerList_.erase(iter);
|
nativePointerList_.erase(iter);
|
||||||
}
|
}
|
||||||
auto newIter = std::find(concurrentNativePointerList_.begin(), concurrentNativePointerList_.end(), pointer);
|
auto newIter = std::find(concurrentNativePointerList_.begin(), concurrentNativePointerList_.end(), pointer);
|
||||||
if (newIter != concurrentNativePointerList_.end()) {
|
if (newIter != concurrentNativePointerList_.end()) {
|
||||||
JSNativePointer *object = *newIter;
|
JSNativePointer *object = *newIter;
|
||||||
nativeAreaAllocator_->DecreaseNativeSizeStats(object->GetBindingSize(), object->GetNativeFlag());
|
nativeAreaAllocator_->DecreaseNativeSizeStats(object->GetBindingSize(), object->GetNativeFlag());
|
||||||
object->Destroy();
|
object->Destroy(thread_);
|
||||||
concurrentNativePointerList_.erase(newIter);
|
concurrentNativePointerList_.erase(newIter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -670,10 +670,10 @@ bool EcmaVM::ContainInDeregisterModuleList(CString module)
|
|||||||
void EcmaVM::ClearBufferData()
|
void EcmaVM::ClearBufferData()
|
||||||
{
|
{
|
||||||
for (auto iter : nativePointerList_) {
|
for (auto iter : nativePointerList_) {
|
||||||
iter->Destroy();
|
iter->Destroy(thread_);
|
||||||
}
|
}
|
||||||
for (auto iter : concurrentNativePointerList_) {
|
for (auto iter : concurrentNativePointerList_) {
|
||||||
iter->Destroy();
|
iter->Destroy(thread_);
|
||||||
}
|
}
|
||||||
nativePointerList_.clear();
|
nativePointerList_.clear();
|
||||||
thread_->GetCurrentEcmaContext()->ClearBufferData();
|
thread_->GetCurrentEcmaContext()->ClearBufferData();
|
||||||
|
@ -102,7 +102,7 @@ using RequestAotCallback =
|
|||||||
using SearchHapPathCallBack = std::function<bool(const std::string moduleName, std::string &hapPath)>;
|
using SearchHapPathCallBack = std::function<bool(const std::string moduleName, std::string &hapPath)>;
|
||||||
using DeviceDisconnectCallback = std::function<bool()>;
|
using DeviceDisconnectCallback = std::function<bool()>;
|
||||||
using UncatchableErrorHandler = std::function<void(panda::TryCatch&)>;
|
using UncatchableErrorHandler = std::function<void(panda::TryCatch&)>;
|
||||||
using DeleteEntryPoint = void (*)(void *, void *);
|
using NativePointerCallback = void (*)(void *, void *, void *);
|
||||||
class EcmaVM {
|
class EcmaVM {
|
||||||
public:
|
public:
|
||||||
static EcmaVM *Create(const JSRuntimeOptions &options);
|
static EcmaVM *Create(const JSRuntimeOptions &options);
|
||||||
@ -666,7 +666,7 @@ public:
|
|||||||
return thread_->GetThreadId();
|
return thread_->GetThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<DeleteEntryPoint, std::pair<void *, void *>>> &GetNativePointerCallbacks()
|
std::vector<std::pair<NativePointerCallback, std::pair<void *, void *>>> &GetNativePointerCallbacks()
|
||||||
{
|
{
|
||||||
return nativePointerCallbacks_;
|
return nativePointerCallbacks_;
|
||||||
}
|
}
|
||||||
@ -683,21 +683,10 @@ public:
|
|||||||
|
|
||||||
static void InitializeIcuData(const JSRuntimeOptions &options);
|
static void InitializeIcuData(const JSRuntimeOptions &options);
|
||||||
|
|
||||||
std::vector<std::pair<DeleteEntryPoint, std::pair<void *, void *>>> &GetSharedNativePointerCallbacks()
|
std::vector<std::pair<NativePointerCallback, std::pair<void *, void *>>> &GetSharedNativePointerCallbacks()
|
||||||
{
|
{
|
||||||
return sharedNativePointerCallbacks_;
|
return sharedNativePointerCallbacks_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *GetEnv() const
|
|
||||||
{
|
|
||||||
return env_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetEnv(void *env)
|
|
||||||
{
|
|
||||||
env_ = env;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void PrintJSErrorInfo(const JSHandle<JSTaggedValue> &exceptionInfo) const;
|
void PrintJSErrorInfo(const JSHandle<JSTaggedValue> &exceptionInfo) const;
|
||||||
@ -728,9 +717,9 @@ private:
|
|||||||
ObjectFactory *factory_ {nullptr};
|
ObjectFactory *factory_ {nullptr};
|
||||||
CList<JSNativePointer *> nativePointerList_;
|
CList<JSNativePointer *> nativePointerList_;
|
||||||
CList<JSNativePointer *> concurrentNativePointerList_;
|
CList<JSNativePointer *> concurrentNativePointerList_;
|
||||||
std::vector<std::pair<DeleteEntryPoint, std::pair<void *, void *>>> nativePointerCallbacks_ {};
|
std::vector<std::pair<NativePointerCallback, std::pair<void *, void *>>> nativePointerCallbacks_ {};
|
||||||
CList<JSNativePointer *> sharedNativePointerList_;
|
CList<JSNativePointer *> sharedNativePointerList_;
|
||||||
std::vector<std::pair<DeleteEntryPoint, std::pair<void *, void *>>> sharedNativePointerCallbacks_ {};
|
std::vector<std::pair<NativePointerCallback, std::pair<void *, void *>>> sharedNativePointerCallbacks_ {};
|
||||||
// VM execution states.
|
// VM execution states.
|
||||||
JSThread *thread_ {nullptr};
|
JSThread *thread_ {nullptr};
|
||||||
|
|
||||||
@ -817,7 +806,6 @@ private:
|
|||||||
bool isEnableOsr_ {false};
|
bool isEnableOsr_ {false};
|
||||||
bool isJitCompileVM_ {false};
|
bool isJitCompileVM_ {false};
|
||||||
bool overLimit_ {false};
|
bool overLimit_ {false};
|
||||||
void *env_ = nullptr;
|
|
||||||
};
|
};
|
||||||
} // namespace ecmascript
|
} // namespace ecmascript
|
||||||
} // namespace panda
|
} // namespace panda
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
globalObject = tObject.release();
|
globalObject = tObject.release();
|
||||||
return reinterpret_cast<T *>(globalObject);
|
return reinterpret_cast<T *>(globalObject);
|
||||||
}
|
}
|
||||||
static void FreeCollatorFormat(void *pointer, void *data)
|
static void FreeCollatorFormat([[maybe_unused]] void *env, void *pointer, void *data)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -146,7 +146,7 @@ public:
|
|||||||
reinterpret_cast<EcmaVM *>(data)->GetNativeAreaAllocator()->FreeBuffer(pointer);
|
reinterpret_cast<EcmaVM *>(data)->GetNativeAreaAllocator()->FreeBuffer(pointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void FreeNumberFormat(void *pointer, void *data)
|
static void FreeNumberFormat([[maybe_unused]] void *env, void *pointer, void *data)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -157,7 +157,7 @@ public:
|
|||||||
reinterpret_cast<EcmaVM *>(data)->GetNativeAreaAllocator()->FreeBuffer(pointer);
|
reinterpret_cast<EcmaVM *>(data)->GetNativeAreaAllocator()->FreeBuffer(pointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void FreeDateTimeFormat(void *pointer, void *data)
|
static void FreeDateTimeFormat([[maybe_unused]] void *env, void *pointer, void *data)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -61,7 +61,7 @@ JSHandle<TaggedArray> JSCollator::GetAvailableLocales(JSThread *thread, bool ena
|
|||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void JSCollator::SetIcuCollator(JSThread *thread, const JSHandle<JSCollator> &collator,
|
void JSCollator::SetIcuCollator(JSThread *thread, const JSHandle<JSCollator> &collator,
|
||||||
icu::Collator *icuCollator, const DeleteEntryPoint &callback)
|
icu::Collator *icuCollator, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -70,7 +70,7 @@ void JSCollator::SetIcuCollator(JSThread *thread, const JSHandle<JSCollator> &co
|
|||||||
JSTaggedValue data = collator->GetIcuField();
|
JSTaggedValue data = collator->GetIcuField();
|
||||||
if (data.IsJSNativePointer()) {
|
if (data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuCollator);
|
native->ResetExternalPointer(thread, icuCollator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuCollator, callback);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuCollator, callback);
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
return reinterpret_cast<icu::Collator *>(result);
|
return reinterpret_cast<icu::Collator *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeIcuCollator(void *pointer, [[maybe_unused]] void *hint = nullptr)
|
static void FreeIcuCollator([[maybe_unused]] void *env, void *pointer, [[maybe_unused]] void *hint = nullptr)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SetIcuCollator(JSThread *thread, const JSHandle<JSCollator> &collator,
|
static void SetIcuCollator(JSThread *thread, const JSHandle<JSCollator> &collator,
|
||||||
icu::Collator *icuCollator, const DeleteEntryPoint &callback);
|
icu::Collator *icuCollator, const NativePointerCallback &callback);
|
||||||
|
|
||||||
// 11.1.1 InitializeCollator ( collator, locales, options )
|
// 11.1.1 InitializeCollator ( collator, locales, options )
|
||||||
static JSHandle<JSCollator> InitializeCollator(JSThread *thread, const JSHandle<JSCollator> &collator,
|
static JSHandle<JSCollator> InitializeCollator(JSThread *thread, const JSHandle<JSCollator> &collator,
|
||||||
|
@ -108,7 +108,7 @@ icu::Locale *JSDateTimeFormat::GetIcuLocale() const
|
|||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void JSDateTimeFormat::SetIcuLocale(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
|
void JSDateTimeFormat::SetIcuLocale(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
|
||||||
const icu::Locale &icuLocale, const DeleteEntryPoint &callback)
|
const icu::Locale &icuLocale, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -117,14 +117,14 @@ void JSDateTimeFormat::SetIcuLocale(JSThread *thread, JSHandle<JSDateTimeFormat>
|
|||||||
JSTaggedValue data = obj->GetLocaleIcu();
|
JSTaggedValue data = obj->GetLocaleIcu();
|
||||||
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuPointer);
|
native->ResetExternalPointer(thread, icuPointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuPointer, callback, ecmaVm);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuPointer, callback, ecmaVm);
|
||||||
obj->SetLocaleIcu(thread, pointer.GetTaggedValue());
|
obj->SetLocaleIcu(thread, pointer.GetTaggedValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSDateTimeFormat::FreeIcuLocale(void *pointer, void *data)
|
void JSDateTimeFormat::FreeIcuLocale([[maybe_unused]] void *env, void *pointer, void *data)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -145,7 +145,7 @@ icu::SimpleDateFormat *JSDateTimeFormat::GetIcuSimpleDateFormat() const
|
|||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void JSDateTimeFormat::SetIcuSimpleDateFormat(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
|
void JSDateTimeFormat::SetIcuSimpleDateFormat(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
|
||||||
const icu::SimpleDateFormat &icuSimpleDateTimeFormat, const DeleteEntryPoint &callback)
|
const icu::SimpleDateFormat &icuSimpleDateTimeFormat, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -155,7 +155,7 @@ void JSDateTimeFormat::SetIcuSimpleDateFormat(JSThread *thread, JSHandle<JSDateT
|
|||||||
JSTaggedValue data = obj->GetSimpleDateTimeFormatIcu();
|
JSTaggedValue data = obj->GetSimpleDateTimeFormatIcu();
|
||||||
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuPointer);
|
native->ResetExternalPointer(thread, icuPointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// According to the observed native memory, we give an approximate native binding value.
|
// According to the observed native memory, we give an approximate native binding value.
|
||||||
@ -165,7 +165,7 @@ void JSDateTimeFormat::SetIcuSimpleDateFormat(JSThread *thread, JSHandle<JSDateT
|
|||||||
obj->SetSimpleDateTimeFormatIcu(thread, pointer.GetTaggedValue());
|
obj->SetSimpleDateTimeFormatIcu(thread, pointer.GetTaggedValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSDateTimeFormat::FreeSimpleDateFormat(void *pointer, void *data)
|
void JSDateTimeFormat::FreeSimpleDateFormat([[maybe_unused]] void *env, void *pointer, void *data)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -122,13 +122,13 @@ public:
|
|||||||
|
|
||||||
icu::Locale *GetIcuLocale() const;
|
icu::Locale *GetIcuLocale() const;
|
||||||
static void SetIcuLocale(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
|
static void SetIcuLocale(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
|
||||||
const icu::Locale &icuLocale, const DeleteEntryPoint &callback);
|
const icu::Locale &icuLocale, const NativePointerCallback &callback);
|
||||||
static void FreeIcuLocale(void *pointer, void *data);
|
static void FreeIcuLocale(void *env, void *pointer, void *data);
|
||||||
|
|
||||||
icu::SimpleDateFormat *GetIcuSimpleDateFormat() const;
|
icu::SimpleDateFormat *GetIcuSimpleDateFormat() const;
|
||||||
static void SetIcuSimpleDateFormat(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
|
static void SetIcuSimpleDateFormat(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
|
||||||
const icu::SimpleDateFormat &icuSimpleDateTimeFormat, const DeleteEntryPoint &callback);
|
const icu::SimpleDateFormat &icuSimpleDateTimeFormat, const NativePointerCallback &callback);
|
||||||
static void FreeSimpleDateFormat(void *pointer, void *data);
|
static void FreeSimpleDateFormat(void *env, void *pointer, void *data);
|
||||||
static icu::SimpleDateFormat *GetCachedIcuSimpleDateFormat(JSThread *thread,
|
static icu::SimpleDateFormat *GetCachedIcuSimpleDateFormat(JSThread *thread,
|
||||||
const JSHandle<JSTaggedValue> &locales,
|
const JSHandle<JSTaggedValue> &locales,
|
||||||
IcuFormatterType type);
|
IcuFormatterType type);
|
||||||
|
@ -53,7 +53,7 @@ icu::LocaleDisplayNames *JSDisplayNames::GetIcuLocaleDisplayNames() const
|
|||||||
return reinterpret_cast<icu::LocaleDisplayNames *>(result);
|
return reinterpret_cast<icu::LocaleDisplayNames *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSDisplayNames::FreeIcuLocaleDisplayNames(void *pointer, [[maybe_unused]] void* hint)
|
void JSDisplayNames::FreeIcuLocaleDisplayNames([[maybe_unused]] void *env, void *pointer, [[maybe_unused]] void* hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -64,7 +64,7 @@ void JSDisplayNames::FreeIcuLocaleDisplayNames(void *pointer, [[maybe_unused]] v
|
|||||||
|
|
||||||
void JSDisplayNames::SetIcuLocaleDisplayNames(JSThread *thread, const JSHandle<JSDisplayNames> &displayNames,
|
void JSDisplayNames::SetIcuLocaleDisplayNames(JSThread *thread, const JSHandle<JSDisplayNames> &displayNames,
|
||||||
icu::LocaleDisplayNames* iculocaledisplaynames,
|
icu::LocaleDisplayNames* iculocaledisplaynames,
|
||||||
const DeleteEntryPoint &callback)
|
const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -73,7 +73,7 @@ void JSDisplayNames::SetIcuLocaleDisplayNames(JSThread *thread, const JSHandle<J
|
|||||||
JSTaggedValue data = displayNames->GetIcuLDN();
|
JSTaggedValue data = displayNames->GetIcuLDN();
|
||||||
if (data.IsJSNativePointer()) {
|
if (data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(iculocaledisplaynames);
|
native->ResetExternalPointer(thread, iculocaledisplaynames);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(iculocaledisplaynames, callback);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(iculocaledisplaynames, callback);
|
||||||
|
@ -78,12 +78,12 @@ public:
|
|||||||
|
|
||||||
icu::LocaleDisplayNames *GetIcuLocaleDisplayNames() const;
|
icu::LocaleDisplayNames *GetIcuLocaleDisplayNames() const;
|
||||||
|
|
||||||
static void FreeIcuLocaleDisplayNames(void *pointer, [[maybe_unused]] void* hint);
|
static void FreeIcuLocaleDisplayNames(void *env, void *pointer, void* hint);
|
||||||
|
|
||||||
static JSHandle<TaggedArray> GetAvailableLocales(JSThread *thread);
|
static JSHandle<TaggedArray> GetAvailableLocales(JSThread *thread);
|
||||||
|
|
||||||
static void SetIcuLocaleDisplayNames(JSThread *thread, const JSHandle<JSDisplayNames> &displayNames,
|
static void SetIcuLocaleDisplayNames(JSThread *thread, const JSHandle<JSDisplayNames> &displayNames,
|
||||||
icu::LocaleDisplayNames* icuPointer, const DeleteEntryPoint &callback);
|
icu::LocaleDisplayNames* icuPointer, const NativePointerCallback &callback);
|
||||||
|
|
||||||
// 12.1.1 CanonicalCodeForDisplayNames ( type, code )
|
// 12.1.1 CanonicalCodeForDisplayNames ( type, code )
|
||||||
static JSHandle<EcmaString> CanonicalCodeForDisplayNames(JSThread *thread,
|
static JSHandle<EcmaString> CanonicalCodeForDisplayNames(JSThread *thread,
|
||||||
|
@ -894,7 +894,7 @@ bool JSFunction::NameSetter(JSThread *thread, const JSHandle<JSObject> &self, co
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSFunction::SetFunctionExtraInfo(JSThread *thread, void *nativeFunc, const DeleteEntryPoint &deleter,
|
void JSFunction::SetFunctionExtraInfo(JSThread *thread, void *nativeFunc, const NativePointerCallback &deleter,
|
||||||
void *data, size_t nativeBindingsize, Concurrent isConcurrent)
|
void *data, size_t nativeBindingsize, Concurrent isConcurrent)
|
||||||
{
|
{
|
||||||
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
|
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
|
||||||
@ -937,7 +937,7 @@ void JSFunction::SetFunctionExtraInfo(JSThread *thread, void *nativeFunc, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JSFunction::SetSFunctionExtraInfo(
|
void JSFunction::SetSFunctionExtraInfo(
|
||||||
JSThread *thread, void *nativeFunc, const DeleteEntryPoint &deleter, void *data, size_t nativeBindingsize)
|
JSThread *thread, void *nativeFunc, const NativePointerCallback &deleter, void *data, size_t nativeBindingsize)
|
||||||
{
|
{
|
||||||
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
|
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
|
||||||
EcmaVM *vm = thread->GetEcmaVM();
|
EcmaVM *vm = thread->GetEcmaVM();
|
||||||
|
@ -220,10 +220,10 @@ public:
|
|||||||
GetClass()->SetClassConstructor(flag);
|
GetClass()->SetClassConstructor(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetFunctionExtraInfo(JSThread *thread, void *nativeFunc, const DeleteEntryPoint &deleter,
|
void SetFunctionExtraInfo(JSThread *thread, void *nativeFunc, const NativePointerCallback &deleter,
|
||||||
void *data, size_t nativeBindingsize = 0, Concurrent isConcurrent = Concurrent::NO);
|
void *data, size_t nativeBindingsize = 0, Concurrent isConcurrent = Concurrent::NO);
|
||||||
void SetSFunctionExtraInfo(
|
void SetSFunctionExtraInfo(JSThread *thread, void *nativeFunc, const NativePointerCallback &deleter,
|
||||||
JSThread *thread, void *nativeFunc, const DeleteEntryPoint &deleter, void *data, size_t nativeBindingsize = 0);
|
void *data, size_t nativeBindingsize = 0);
|
||||||
|
|
||||||
JSTaggedValue GetFunctionExtraInfo() const;
|
JSTaggedValue GetFunctionExtraInfo() const;
|
||||||
JSTaggedValue GetNativeFunctionExtraInfo() const;
|
JSTaggedValue GetNativeFunctionExtraInfo() const;
|
||||||
|
@ -44,7 +44,7 @@ icu::ListFormatter *JSListFormat::GetIcuListFormatter() const
|
|||||||
return reinterpret_cast<icu::ListFormatter *>(result);
|
return reinterpret_cast<icu::ListFormatter *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSListFormat::FreeIcuListFormatter(void *pointer, [[maybe_unused]] void* hint)
|
void JSListFormat::FreeIcuListFormatter([[maybe_unused]] void *env, void *pointer, [[maybe_unused]] void* hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -55,7 +55,7 @@ void JSListFormat::FreeIcuListFormatter(void *pointer, [[maybe_unused]] void* hi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JSListFormat::SetIcuListFormatter(JSThread *thread, const JSHandle<JSListFormat> listFormat,
|
void JSListFormat::SetIcuListFormatter(JSThread *thread, const JSHandle<JSListFormat> listFormat,
|
||||||
icu::ListFormatter *icuListFormatter, const DeleteEntryPoint &callback)
|
icu::ListFormatter *icuListFormatter, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -63,7 +63,7 @@ void JSListFormat::SetIcuListFormatter(JSThread *thread, const JSHandle<JSListFo
|
|||||||
JSTaggedValue data = listFormat->GetIcuLF();
|
JSTaggedValue data = listFormat->GetIcuLF();
|
||||||
if (data.IsJSNativePointer()) {
|
if (data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuListFormatter);
|
native->ResetExternalPointer(thread, icuListFormatter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuListFormatter, callback);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuListFormatter, callback);
|
||||||
|
@ -61,10 +61,10 @@ public:
|
|||||||
|
|
||||||
icu::ListFormatter *GetIcuListFormatter() const;
|
icu::ListFormatter *GetIcuListFormatter() const;
|
||||||
|
|
||||||
static void FreeIcuListFormatter(void *pointer, [[maybe_unused]] void* hint);
|
static void FreeIcuListFormatter(void *env, void *pointer, [[maybe_unused]] void* hint);
|
||||||
|
|
||||||
static void SetIcuListFormatter(JSThread *thread, const JSHandle<JSListFormat> obj,
|
static void SetIcuListFormatter(JSThread *thread, const JSHandle<JSListFormat> obj,
|
||||||
icu::ListFormatter *icuListFormatter, const DeleteEntryPoint &callback);
|
icu::ListFormatter *icuListFormatter, const NativePointerCallback &callback);
|
||||||
|
|
||||||
static JSHandle<TaggedArray> GetAvailableLocales(JSThread *thread);
|
static JSHandle<TaggedArray> GetAvailableLocales(JSThread *thread);
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ public:
|
|||||||
return reinterpret_cast<icu::Locale *>(result);
|
return reinterpret_cast<icu::Locale *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeIcuLocale(void *pointer, void *data)
|
static void FreeIcuLocale([[maybe_unused]] void *env, void *pointer, void *data)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -17,12 +17,11 @@
|
|||||||
#define ECMASCRIPT_JSNATIVEPOINTER_H
|
#define ECMASCRIPT_JSNATIVEPOINTER_H
|
||||||
|
|
||||||
#include "ecmascript/ecma_macros.h"
|
#include "ecmascript/ecma_macros.h"
|
||||||
|
#include "ecmascript/js_thread.h"
|
||||||
#include "ecmascript/mem/tagged_object.h"
|
#include "ecmascript/mem/tagged_object.h"
|
||||||
#include "ecmascript/mem/native_area_allocator.h"
|
#include "ecmascript/mem/native_area_allocator.h"
|
||||||
|
|
||||||
namespace panda::ecmascript {
|
namespace panda::ecmascript {
|
||||||
using DeleteEntryPoint = void (*)(void *, void *);
|
|
||||||
|
|
||||||
// Used for the requirement of ACE that wants to associated a registered C++ resource with a JSObject.
|
// Used for the requirement of ACE that wants to associated a registered C++ resource with a JSObject.
|
||||||
class JSNativePointer : public TaggedObject {
|
class JSNativePointer : public TaggedObject {
|
||||||
public:
|
public:
|
||||||
@ -32,15 +31,15 @@ public:
|
|||||||
return reinterpret_cast<JSNativePointer *>(object);
|
return reinterpret_cast<JSNativePointer *>(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ResetExternalPointer(void *externalPointer)
|
inline void ResetExternalPointer(JSThread *thread, void *externalPointer)
|
||||||
{
|
{
|
||||||
DeleteExternalPointer();
|
DeleteExternalPointer(thread);
|
||||||
SetExternalPointer(externalPointer);
|
SetExternalPointer(externalPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Destroy()
|
inline void Destroy(JSThread *thread)
|
||||||
{
|
{
|
||||||
DeleteExternalPointer();
|
DeleteExternalPointer(thread);
|
||||||
SetExternalPointer(nullptr);
|
SetExternalPointer(nullptr);
|
||||||
SetDeleter(nullptr);
|
SetDeleter(nullptr);
|
||||||
SetData(nullptr);
|
SetData(nullptr);
|
||||||
@ -55,7 +54,7 @@ public:
|
|||||||
|
|
||||||
static constexpr size_t POINTER_OFFSET = TaggedObjectSize();
|
static constexpr size_t POINTER_OFFSET = TaggedObjectSize();
|
||||||
ACCESSORS_NATIVE_FIELD(ExternalPointer, void, POINTER_OFFSET, DELETER_OFFSET);
|
ACCESSORS_NATIVE_FIELD(ExternalPointer, void, POINTER_OFFSET, DELETER_OFFSET);
|
||||||
ACCESSORS_PRIMITIVE_FIELD(Deleter, DeleteEntryPoint, DELETER_OFFSET, DATA_OFFSET)
|
ACCESSORS_PRIMITIVE_FIELD(Deleter, NativePointerCallback, DELETER_OFFSET, DATA_OFFSET)
|
||||||
ACCESSORS_NATIVE_FIELD(Data, void, DATA_OFFSET, DATA_SIZE_OFFSET);
|
ACCESSORS_NATIVE_FIELD(Data, void, DATA_OFFSET, DATA_SIZE_OFFSET);
|
||||||
ACCESSORS_PRIMITIVE_FIELD(BindingSize, uint64_t, DATA_SIZE_OFFSET, FLAG_OFFSET);
|
ACCESSORS_PRIMITIVE_FIELD(BindingSize, uint64_t, DATA_SIZE_OFFSET, FLAG_OFFSET);
|
||||||
// native memory statistic flag
|
// native memory statistic flag
|
||||||
@ -65,12 +64,13 @@ public:
|
|||||||
DECL_VISIT_NATIVE_FIELD(POINTER_OFFSET, DATA_SIZE_OFFSET)
|
DECL_VISIT_NATIVE_FIELD(POINTER_OFFSET, DATA_SIZE_OFFSET)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void DeleteExternalPointer()
|
inline void DeleteExternalPointer(JSThread *thread)
|
||||||
{
|
{
|
||||||
void *externalPointer = GetExternalPointer();
|
void *externalPointer = GetExternalPointer();
|
||||||
DeleteEntryPoint deleter = GetDeleter();
|
NativePointerCallback deleter = GetDeleter();
|
||||||
|
auto env = thread->GetEnv();
|
||||||
if (deleter != nullptr) {
|
if (deleter != nullptr) {
|
||||||
deleter(externalPointer, GetData());
|
deleter(env, externalPointer, GetData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -98,7 +98,7 @@ public:
|
|||||||
return reinterpret_cast<icu::number::LocalizedNumberFormatter *>(result);
|
return reinterpret_cast<icu::number::LocalizedNumberFormatter *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeIcuNumberformat(void *pointer, void *data)
|
static void FreeIcuNumberformat([[maybe_unused]] void *env, void *pointer, void *data)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -2882,7 +2882,7 @@ void *ECMAObject::GetNativePointerField(int32_t index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ECMAObject::SetNativePointerField(const JSThread *thread, int32_t index, void *nativePointer,
|
void ECMAObject::SetNativePointerField(const JSThread *thread, int32_t index, void *nativePointer,
|
||||||
const DeleteEntryPoint &callBack, void *data, size_t nativeBindingsize, Concurrent isConcurrent)
|
const NativePointerCallback &callBack, void *data, size_t nativeBindingsize, Concurrent isConcurrent)
|
||||||
{
|
{
|
||||||
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
|
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
|
||||||
JSTaggedValue value(hashField);
|
JSTaggedValue value(hashField);
|
||||||
|
@ -384,7 +384,7 @@ public:
|
|||||||
|
|
||||||
void* GetNativePointerField(int32_t index) const;
|
void* GetNativePointerField(int32_t index) const;
|
||||||
void SetNativePointerField(const JSThread *thread, int32_t index, void *nativePointer,
|
void SetNativePointerField(const JSThread *thread, int32_t index, void *nativePointer,
|
||||||
const DeleteEntryPoint &callBack, void *data, size_t nativeBindingsize = 0,
|
const NativePointerCallback &callBack, void *data, size_t nativeBindingsize = 0,
|
||||||
Concurrent isConcurrent = Concurrent::NO);
|
Concurrent isConcurrent = Concurrent::NO);
|
||||||
int32_t GetNativePointerFieldCount() const;
|
int32_t GetNativePointerFieldCount() const;
|
||||||
void SetNativePointerFieldCount(const JSThread *thread, int32_t count);
|
void SetNativePointerFieldCount(const JSThread *thread, int32_t count);
|
||||||
|
@ -33,7 +33,7 @@ icu::number::LocalizedNumberFormatter *JSPluralRules::GetIcuNumberFormatter() co
|
|||||||
return reinterpret_cast<icu::number::LocalizedNumberFormatter *>(result);
|
return reinterpret_cast<icu::number::LocalizedNumberFormatter *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSPluralRules::FreeIcuNumberFormatter(void *pointer, void* hint)
|
void JSPluralRules::FreeIcuNumberFormatter([[maybe_unused]] void *env, void *pointer, void* hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -46,7 +46,7 @@ void JSPluralRules::FreeIcuNumberFormatter(void *pointer, void* hint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JSPluralRules::SetIcuNumberFormatter(JSThread *thread, const JSHandle<JSPluralRules> &pluralRules,
|
void JSPluralRules::SetIcuNumberFormatter(JSThread *thread, const JSHandle<JSPluralRules> &pluralRules,
|
||||||
const icu::number::LocalizedNumberFormatter &icuNF, const DeleteEntryPoint &callback)
|
const icu::number::LocalizedNumberFormatter &icuNF, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -57,7 +57,7 @@ void JSPluralRules::SetIcuNumberFormatter(JSThread *thread, const JSHandle<JSPlu
|
|||||||
JSTaggedValue data = pluralRules->GetIcuNF();
|
JSTaggedValue data = pluralRules->GetIcuNF();
|
||||||
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuPointer);
|
native->ResetExternalPointer(thread, icuPointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuPointer, callback, ecmaVm);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuPointer, callback, ecmaVm);
|
||||||
@ -71,7 +71,7 @@ icu::PluralRules *JSPluralRules::GetIcuPluralRules() const
|
|||||||
return reinterpret_cast<icu::PluralRules *>(result);
|
return reinterpret_cast<icu::PluralRules *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSPluralRules::FreeIcuPluralRules(void *pointer, void* hint)
|
void JSPluralRules::FreeIcuPluralRules([[maybe_unused]] void *env, void *pointer, void* hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -84,7 +84,7 @@ void JSPluralRules::FreeIcuPluralRules(void *pointer, void* hint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JSPluralRules::SetIcuPluralRules(JSThread *thread, const JSHandle<JSPluralRules> &pluralRules,
|
void JSPluralRules::SetIcuPluralRules(JSThread *thread, const JSHandle<JSPluralRules> &pluralRules,
|
||||||
const icu::PluralRules &icuPR, const DeleteEntryPoint &callback)
|
const icu::PluralRules &icuPR, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
[[maybe_unused]] EcmaHandleScope scope(thread);
|
[[maybe_unused]] EcmaHandleScope scope(thread);
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
@ -95,7 +95,7 @@ void JSPluralRules::SetIcuPluralRules(JSThread *thread, const JSHandle<JSPluralR
|
|||||||
JSTaggedValue data = pluralRules->GetIcuPR();
|
JSTaggedValue data = pluralRules->GetIcuPR();
|
||||||
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuPointer);
|
native->ResetExternalPointer(thread, icuPointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuPointer, callback, ecmaVm);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuPointer, callback, ecmaVm);
|
||||||
|
@ -55,16 +55,16 @@ public:
|
|||||||
icu::number::LocalizedNumberFormatter *GetIcuNumberFormatter() const;
|
icu::number::LocalizedNumberFormatter *GetIcuNumberFormatter() const;
|
||||||
|
|
||||||
static void SetIcuNumberFormatter(JSThread *thread, const JSHandle<JSPluralRules> &pluralRules,
|
static void SetIcuNumberFormatter(JSThread *thread, const JSHandle<JSPluralRules> &pluralRules,
|
||||||
const icu::number::LocalizedNumberFormatter &icuNF, const DeleteEntryPoint &callback);
|
const icu::number::LocalizedNumberFormatter &icuNF, const NativePointerCallback &callback);
|
||||||
|
|
||||||
static void FreeIcuNumberFormatter(void *pointer, [[maybe_unused]] void* hint = nullptr);
|
static void FreeIcuNumberFormatter(void *env, void *pointer, void* hint = nullptr);
|
||||||
|
|
||||||
icu::PluralRules *GetIcuPluralRules() const;
|
icu::PluralRules *GetIcuPluralRules() const;
|
||||||
|
|
||||||
static void SetIcuPluralRules(JSThread *thread, const JSHandle<JSPluralRules> &pluralRules,
|
static void SetIcuPluralRules(JSThread *thread, const JSHandle<JSPluralRules> &pluralRules,
|
||||||
const icu::PluralRules &icuPR, const DeleteEntryPoint &callback);
|
const icu::PluralRules &icuPR, const NativePointerCallback &callback);
|
||||||
|
|
||||||
static void FreeIcuPluralRules(void *pointer, [[maybe_unused]] void* hint = nullptr);
|
static void FreeIcuPluralRules(void *env, void *pointer, void* hint = nullptr);
|
||||||
|
|
||||||
static JSHandle<TaggedArray> BuildLocaleSet(JSThread *thread, const std::set<std::string> &icuAvailableLocales);
|
static JSHandle<TaggedArray> BuildLocaleSet(JSThread *thread, const std::set<std::string> &icuAvailableLocales);
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
return reinterpret_cast<icu::RelativeDateTimeFormatter *>(result);
|
return reinterpret_cast<icu::RelativeDateTimeFormatter *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeIcuRTFFormatter(void *pointer, void *data)
|
static void FreeIcuRTFFormatter([[maybe_unused]] void *env, void *pointer, void *data)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
namespace panda::ecmascript {
|
namespace panda::ecmascript {
|
||||||
|
|
||||||
void JSSegmentIterator::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegmentIterator> &iterator,
|
void JSSegmentIterator::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegmentIterator> &iterator,
|
||||||
icu::BreakIterator* icuBreakIterator, const DeleteEntryPoint &callback)
|
icu::BreakIterator* icuBreakIterator, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -46,7 +46,7 @@ void JSSegmentIterator::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSS
|
|||||||
JSTaggedValue data = iterator->GetIcuField();
|
JSTaggedValue data = iterator->GetIcuField();
|
||||||
if (data.IsJSNativePointer()) {
|
if (data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuBreakIterator);
|
native->ResetExternalPointer(thread, icuBreakIterator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuBreakIterator, callback);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuBreakIterator, callback);
|
||||||
@ -54,7 +54,7 @@ void JSSegmentIterator::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSS
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JSSegmentIterator::SetUString(JSThread *thread, const JSHandle<JSSegmentIterator> &iterator,
|
void JSSegmentIterator::SetUString(JSThread *thread, const JSHandle<JSSegmentIterator> &iterator,
|
||||||
icu::UnicodeString* icuUnicodeString, const DeleteEntryPoint &callback)
|
icu::UnicodeString* icuUnicodeString, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -63,7 +63,7 @@ void JSSegmentIterator::SetUString(JSThread *thread, const JSHandle<JSSegmentIte
|
|||||||
JSTaggedValue data = iterator->GetUnicodeString();
|
JSTaggedValue data = iterator->GetUnicodeString();
|
||||||
if (data.IsJSNativePointer()) {
|
if (data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuUnicodeString);
|
native->ResetExternalPointer(thread, icuUnicodeString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuUnicodeString, callback);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuUnicodeString, callback);
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
return reinterpret_cast<icu::BreakIterator *>(result);
|
return reinterpret_cast<icu::BreakIterator *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeIcuBreakIterator(void *pointer, [[maybe_unused]] void* hint)
|
static void FreeIcuBreakIterator([[maybe_unused]] void *env, void *pointer, [[maybe_unused]] void* hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -75,9 +75,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegmentIterator> &iterator,
|
static void SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegmentIterator> &iterator,
|
||||||
icu::BreakIterator* icuBreakIterator, const DeleteEntryPoint &callback);
|
icu::BreakIterator* icuBreakIterator, const NativePointerCallback &callback);
|
||||||
|
|
||||||
static void FreeUString(void *pointer, [[maybe_unused]] void* hint)
|
static void FreeUString([[maybe_unused]] void *env, void *pointer, [[maybe_unused]] void* hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -87,7 +87,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SetUString(JSThread *thread, const JSHandle<JSSegmentIterator> &iterator,
|
static void SetUString(JSThread *thread, const JSHandle<JSSegmentIterator> &iterator,
|
||||||
icu::UnicodeString* icuUnicodeString, const DeleteEntryPoint &callback);
|
icu::UnicodeString* icuUnicodeString, const NativePointerCallback &callback);
|
||||||
|
|
||||||
icu::UnicodeString *GetUString() const
|
icu::UnicodeString *GetUString() const
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
namespace panda::ecmascript {
|
namespace panda::ecmascript {
|
||||||
|
|
||||||
void JSSegmenter::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegmenter> &segmenter,
|
void JSSegmenter::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegmenter> &segmenter,
|
||||||
icu::BreakIterator* icuBreakIterator, const DeleteEntryPoint &callback)
|
icu::BreakIterator* icuBreakIterator, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -43,7 +43,7 @@ void JSSegmenter::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegment
|
|||||||
JSTaggedValue data = segmenter->GetIcuField();
|
JSTaggedValue data = segmenter->GetIcuField();
|
||||||
if (data.IsJSNativePointer()) {
|
if (data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuBreakIterator);
|
native->ResetExternalPointer(thread, icuBreakIterator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuBreakIterator, callback);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuBreakIterator, callback);
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
return reinterpret_cast<icu::BreakIterator *>(result);
|
return reinterpret_cast<icu::BreakIterator *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeIcuBreakIterator(void *pointer, [[maybe_unused]] void* hint)
|
static void FreeIcuBreakIterator([[maybe_unused]] void *env, void *pointer, [[maybe_unused]] void* hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -76,7 +76,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegmenter> &segmenter,
|
static void SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegmenter> &segmenter,
|
||||||
icu::BreakIterator* icuBreakIterator, const DeleteEntryPoint &callback);
|
icu::BreakIterator* icuBreakIterator, const NativePointerCallback &callback);
|
||||||
|
|
||||||
static JSHandle<TaggedArray> GetAvailableLocales(JSThread *thread);
|
static JSHandle<TaggedArray> GetAvailableLocales(JSThread *thread);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
namespace panda::ecmascript {
|
namespace panda::ecmascript {
|
||||||
|
|
||||||
void JSSegments::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegments> &segments,
|
void JSSegments::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegments> &segments,
|
||||||
icu::BreakIterator* icuBreakIterator, const DeleteEntryPoint &callback)
|
icu::BreakIterator* icuBreakIterator, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -44,7 +44,7 @@ void JSSegments::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegments
|
|||||||
JSTaggedValue data = segments->GetIcuField();
|
JSTaggedValue data = segments->GetIcuField();
|
||||||
if (data.IsJSNativePointer()) {
|
if (data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuBreakIterator);
|
native->ResetExternalPointer(thread, icuBreakIterator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuBreakIterator, callback);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuBreakIterator, callback);
|
||||||
@ -52,7 +52,7 @@ void JSSegments::SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegments
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JSSegments::SetUString(JSThread *thread, const JSHandle<JSSegments> &segments,
|
void JSSegments::SetUString(JSThread *thread, const JSHandle<JSSegments> &segments,
|
||||||
icu::UnicodeString* icuUnicodeString, const DeleteEntryPoint &callback)
|
icu::UnicodeString* icuUnicodeString, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||||
@ -61,7 +61,7 @@ void JSSegments::SetUString(JSThread *thread, const JSHandle<JSSegments> &segmen
|
|||||||
JSTaggedValue data = segments->GetUnicodeString();
|
JSTaggedValue data = segments->GetUnicodeString();
|
||||||
if (data.IsJSNativePointer()) {
|
if (data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuUnicodeString);
|
native->ResetExternalPointer(thread, icuUnicodeString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuUnicodeString, callback);
|
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(icuUnicodeString, callback);
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
return reinterpret_cast<icu::BreakIterator *>(result);
|
return reinterpret_cast<icu::BreakIterator *>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeIcuBreakIterator(void *pointer, [[maybe_unused]] void* hint)
|
static void FreeIcuBreakIterator([[maybe_unused]] void *env, void *pointer, [[maybe_unused]] void* hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -71,9 +71,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegments> &segments,
|
static void SetIcuBreakIterator(JSThread *thread, const JSHandle<JSSegments> &segments,
|
||||||
icu::BreakIterator* icuBreakIterator, const DeleteEntryPoint &callback);
|
icu::BreakIterator* icuBreakIterator, const NativePointerCallback &callback);
|
||||||
|
|
||||||
static void FreeUString(void *pointer, [[maybe_unused]] void* hint)
|
static void FreeUString([[maybe_unused]] void *env, void *pointer, [[maybe_unused]] void* hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -83,7 +83,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SetUString(JSThread *thread, const JSHandle<JSSegments> &segments,
|
static void SetUString(JSThread *thread, const JSHandle<JSSegments> &segments,
|
||||||
icu::UnicodeString* icuUnicodeString, const DeleteEntryPoint &callback);
|
icu::UnicodeString* icuUnicodeString, const NativePointerCallback &callback);
|
||||||
|
|
||||||
icu::UnicodeString *GetUString() const
|
icu::UnicodeString *GetUString() const
|
||||||
{
|
{
|
||||||
|
@ -1784,7 +1784,7 @@ JSHandle<JSTaggedValue> JSDeserializer::ReadJSNativePointer()
|
|||||||
return JSHandle<JSTaggedValue>();
|
return JSHandle<JSTaggedValue>();
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> np = factory_->NewJSNativePointer(ToVoidPtr(externalPtr),
|
JSHandle<JSNativePointer> np = factory_->NewJSNativePointer(ToVoidPtr(externalPtr),
|
||||||
reinterpret_cast<DeleteEntryPoint>(deleter),
|
reinterpret_cast<NativePointerCallback>(deleter),
|
||||||
ToVoidPtr(allocatorPtr),
|
ToVoidPtr(allocatorPtr),
|
||||||
false,
|
false,
|
||||||
bindingSize);
|
bindingSize);
|
||||||
|
@ -242,7 +242,7 @@ void JSThread::InvokeSharedNativePointerCallbacks()
|
|||||||
ASSERT(callbackPair.first != nullptr && callbackPair.second.first != nullptr &&
|
ASSERT(callbackPair.first != nullptr && callbackPair.second.first != nullptr &&
|
||||||
callbackPair.second.second != nullptr);
|
callbackPair.second.second != nullptr);
|
||||||
auto callback = callbackPair.first;
|
auto callback = callbackPair.first;
|
||||||
(*callback)(callbackPair.second.first, callbackPair.second.second);
|
(*callback)(env_, callbackPair.second.first, callbackPair.second.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1267,6 +1267,16 @@ public:
|
|||||||
{
|
{
|
||||||
return machineCodeLowMemory_;
|
return machineCodeLowMemory_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *GetEnv() const
|
||||||
|
{
|
||||||
|
return env_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetEnv(void *env)
|
||||||
|
{
|
||||||
|
env_ = env;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
NO_COPY_SEMANTIC(JSThread);
|
NO_COPY_SEMANTIC(JSThread);
|
||||||
NO_MOVE_SEMANTIC(JSThread);
|
NO_MOVE_SEMANTIC(JSThread);
|
||||||
@ -1315,6 +1325,7 @@ private:
|
|||||||
GlueData glueData_;
|
GlueData glueData_;
|
||||||
std::atomic<ThreadId> id_;
|
std::atomic<ThreadId> id_;
|
||||||
EcmaVM *vm_ {nullptr};
|
EcmaVM *vm_ {nullptr};
|
||||||
|
void *env_ {nullptr};
|
||||||
Area *regExpCache_ {nullptr};
|
Area *regExpCache_ {nullptr};
|
||||||
|
|
||||||
// MM: handles, global-handles, and aot-stubs.
|
// MM: handles, global-handles, and aot-stubs.
|
||||||
|
@ -1761,7 +1761,7 @@ void Heap::CleanCallBack()
|
|||||||
auto &callbacks = this->GetEcmaVM()->GetNativePointerCallbacks();
|
auto &callbacks = this->GetEcmaVM()->GetNativePointerCallbacks();
|
||||||
if (!callbacks.empty()) {
|
if (!callbacks.empty()) {
|
||||||
Taskpool::GetCurrentTaskpool()->PostTask(
|
Taskpool::GetCurrentTaskpool()->PostTask(
|
||||||
std::make_unique<DeleteCallbackTask>(this->GetJSThread()->GetThreadId(), callbacks)
|
std::make_unique<DeleteCallbackTask>(thread_, thread_->GetThreadId(), callbacks)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ASSERT(callbacks.empty());
|
ASSERT(callbacks.empty());
|
||||||
@ -1771,7 +1771,7 @@ bool Heap::DeleteCallbackTask::Run([[maybe_unused]] uint32_t threadIndex)
|
|||||||
{
|
{
|
||||||
for (auto iter : nativePointerCallbacks_) {
|
for (auto iter : nativePointerCallbacks_) {
|
||||||
if (iter.first != nullptr) {
|
if (iter.first != nullptr) {
|
||||||
iter.first(iter.second.first, iter.second.second);
|
iter.first(thread_, iter.second.first, iter.second.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1095,8 +1095,9 @@ private:
|
|||||||
|
|
||||||
class DeleteCallbackTask : public Task {
|
class DeleteCallbackTask : public Task {
|
||||||
public:
|
public:
|
||||||
DeleteCallbackTask(int32_t id, std::vector<std::pair<DeleteEntryPoint, std::pair<void *, void *>>> &callbacks)
|
DeleteCallbackTask(JSThread *thread, int32_t id,
|
||||||
: Task(id)
|
std::vector<std::pair<NativePointerCallback, std::pair<void *, void *>>> &callbacks)
|
||||||
|
: Task(id), thread_(thread)
|
||||||
{
|
{
|
||||||
std::swap(callbacks, nativePointerCallbacks_);
|
std::swap(callbacks, nativePointerCallbacks_);
|
||||||
};
|
};
|
||||||
@ -1107,7 +1108,8 @@ private:
|
|||||||
NO_MOVE_SEMANTIC(DeleteCallbackTask);
|
NO_MOVE_SEMANTIC(DeleteCallbackTask);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::pair<DeleteEntryPoint, std::pair<void *, void *>>> nativePointerCallbacks_ {};
|
std::vector<std::pair<NativePointerCallback, std::pair<void *, void *>>> nativePointerCallbacks_ {};
|
||||||
|
JSThread *thread_ {nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
class RecursionScope {
|
class RecursionScope {
|
||||||
|
@ -128,7 +128,7 @@ void NativeAreaAllocator::FreeBuffer(void *mem)
|
|||||||
free(mem);
|
free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeAreaAllocator::FreeBufferFunc(void *buffer, void *data)
|
void NativeAreaAllocator::FreeBufferFunc([[maybe_unused]] void *env, void *buffer, void *data)
|
||||||
{
|
{
|
||||||
if (buffer == nullptr || data == nullptr) {
|
if (buffer == nullptr || data == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -49,10 +49,10 @@ public:
|
|||||||
void *AllocateBuffer(size_t size);
|
void *AllocateBuffer(size_t size);
|
||||||
void FreeBuffer(void *mem);
|
void FreeBuffer(void *mem);
|
||||||
|
|
||||||
static void FreeBufferFunc(void* buffer, void* data);
|
static void FreeBufferFunc(void *env, void* buffer, void* data);
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
static void FreeObjectFunc(void* buffer, void* data)
|
static void FreeObjectFunc([[maybe_unused]] void *env, void* buffer, void* data)
|
||||||
{
|
{
|
||||||
if (buffer == nullptr || data == nullptr) {
|
if (buffer == nullptr || data == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
namespace panda::ecmascript {
|
namespace panda::ecmascript {
|
||||||
using PathHelper = base::PathHelper;
|
using PathHelper = base::PathHelper;
|
||||||
|
|
||||||
void ModuleDeregister::FreeModuleRecord(void *pointer, void *hint)
|
void ModuleDeregister::FreeModuleRecord([[maybe_unused]] void *env, void *pointer, void *hint)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
LOG_FULL(FATAL) << "Lacking deregister module's name.";
|
LOG_FULL(FATAL) << "Lacking deregister module's name.";
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
moduleRecord->SetNamespace(thread, weakNameSp);
|
moduleRecord->SetNamespace(thread, weakNameSp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeModuleRecord(void *pointer, void *hint);
|
static void FreeModuleRecord(void *env, void *pointer, void *hint);
|
||||||
|
|
||||||
static void RemoveModule(JSThread *thread, JSHandle<SourceTextModule> module);
|
static void RemoveModule(JSThread *thread, JSHandle<SourceTextModule> module);
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ bool ModuleNamespace::ValidateKeysAvailable(JSThread *thread, const JSHandle<Tag
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ModuleNamespace::SetModuleDeregisterProcession(JSThread *thread, const JSHandle<ModuleNamespace> &nameSpace,
|
void ModuleNamespace::SetModuleDeregisterProcession(JSThread *thread, const JSHandle<ModuleNamespace> &nameSpace,
|
||||||
const DeleteEntryPoint &callback)
|
const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
CAST_CHECK(ModuleNamespace, IsModuleNamespace);
|
CAST_CHECK(ModuleNamespace, IsModuleNamespace);
|
||||||
|
|
||||||
static void SetModuleDeregisterProcession(JSThread *thread, const JSHandle<ModuleNamespace> &nameSpace,
|
static void SetModuleDeregisterProcession(JSThread *thread, const JSHandle<ModuleNamespace> &nameSpace,
|
||||||
const DeleteEntryPoint &callback);
|
const NativePointerCallback &callback);
|
||||||
|
|
||||||
// 9.4.6.11ModuleNamespaceCreate ( module, exports )
|
// 9.4.6.11ModuleNamespaceCreate ( module, exports )
|
||||||
static JSHandle<ModuleNamespace> ModuleNamespaceCreate(JSThread *thread, const JSHandle<JSTaggedValue> &module,
|
static JSHandle<ModuleNamespace> ModuleNamespaceCreate(JSThread *thread, const JSHandle<JSTaggedValue> &module,
|
||||||
|
@ -6,7 +6,7 @@ ArrayBufferRef
|
|||||||
|
|
||||||
Local<ArrayBufferRef> ArrayBufferRef::New(const EcmaVM *vm, int32_t length);
|
Local<ArrayBufferRef> ArrayBufferRef::New(const EcmaVM *vm, int32_t length);
|
||||||
|
|
||||||
Local<ArrayBufferRef> ArrayBufferRef::New(const EcmaVM *vm, void *buffer, int32_t length, const Deleter &deleter, void *data);
|
Local<ArrayBufferRef> ArrayBufferRef::New(const EcmaVM *vm, void *buffer, int32_t length, const NativePointerCallback &deleter, void *data);
|
||||||
|
|
||||||
创建一个ArrayBuffer对象。
|
创建一个ArrayBuffer对象。
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ Local<ArrayBufferRef> ArrayBufferRef::New(const EcmaVM *vm, void *buffer, int32_
|
|||||||
| vm | const EcmaVM * | 是 | 虚拟机对象。 |
|
| vm | const EcmaVM * | 是 | 虚拟机对象。 |
|
||||||
| length | int32_t | 是 | 指定的长度。 |
|
| length | int32_t | 是 | 指定的长度。 |
|
||||||
| buffer | void * | 是 | 指定缓冲区。 |
|
| buffer | void * | 是 | 指定缓冲区。 |
|
||||||
| deleter | const Deleter & | 是 | 删除ArrayBuffer时所作的操作 |
|
| deleter | const NativePointerCallback & | 是 | 删除ArrayBuffer时所作的操作 |
|
||||||
| data | void * | 是 | 指定数据。 |
|
| data | void * | 是 | 指定数据。 |
|
||||||
|
|
||||||
**返回值:**
|
**返回值:**
|
||||||
@ -33,7 +33,7 @@ Local<ArrayBufferRef> arrayBuffer1 = ArrayBufferRef::New(vm, 10);
|
|||||||
uint8_t *buffer = new uint8_t[10]();
|
uint8_t *buffer = new uint8_t[10]();
|
||||||
int *data = new int;
|
int *data = new int;
|
||||||
*data = 10;
|
*data = 10;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
int *currentData = reinterpret_cast<int *>(data);
|
int *currentData = reinterpret_cast<int *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
@ -65,7 +65,7 @@ void *ArrayBufferRef::GetBuffer()
|
|||||||
uint8_t *buffer = new uint8_t[10]();
|
uint8_t *buffer = new uint8_t[10]();
|
||||||
int *data = new int;
|
int *data = new int;
|
||||||
*data = 10;
|
*data = 10;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
int *currentData = reinterpret_cast<int *>(data);
|
int *currentData = reinterpret_cast<int *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
@ -188,7 +188,7 @@ Local<BooleanRef> boolRef = BooleanRef::New(vm, true);
|
|||||||
|
|
||||||
Local<BufferRef> BufferRef::New(const EcmaVM *vm, int32_t length);
|
Local<BufferRef> BufferRef::New(const EcmaVM *vm, int32_t length);
|
||||||
|
|
||||||
Local<BufferRef> BufferRef::New(const EcmaVM *vm, void *buffer, int32_t length, const Deleter &deleter, void *data)
|
Local<BufferRef> BufferRef::New(const EcmaVM *vm, void *buffer, int32_t length, const NativePointerCallback &deleter, void *data)
|
||||||
|
|
||||||
创建一个BufferRef对象。
|
创建一个BufferRef对象。
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ Local<BufferRef> BufferRef::New(const EcmaVM *vm, void *buffer, int32_t length,
|
|||||||
| vm | const EcmaVM * | 是 | 虚拟机对象。 |
|
| vm | const EcmaVM * | 是 | 虚拟机对象。 |
|
||||||
| length | int32_t | 是 | 指定的长度。 |
|
| length | int32_t | 是 | 指定的长度。 |
|
||||||
| buffer | void * | 是 | 指定缓冲区 |
|
| buffer | void * | 是 | 指定缓冲区 |
|
||||||
| deleter | const Deleter & | 是 | 一个删除器对象,用于在不再需要缓冲区时释放其内存。 |
|
| deleter | const NativePointerCallback & | 是 | 一个删除器对象,用于在不再需要缓冲区时释放其内存。 |
|
||||||
| data | void * | 是 | 传递给删除器的额外数据。 |
|
| data | void * | 是 | 传递给删除器的额外数据。 |
|
||||||
|
|
||||||
**返回值:**
|
**返回值:**
|
||||||
@ -215,7 +215,7 @@ Local<BufferRef> bufferRef1 = BufferRef::New(vm, 10);
|
|||||||
uint8_t *buffer = new uint8_t[10]();
|
uint8_t *buffer = new uint8_t[10]();
|
||||||
int *data = new int;
|
int *data = new int;
|
||||||
*data = 10;
|
*data = 10;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
int *currentData = reinterpret_cast<int *>(data);
|
int *currentData = reinterpret_cast<int *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
@ -272,7 +272,7 @@ void *BufferRef::GetBuffer()
|
|||||||
uint8_t *buffer = new uint8_t[10]();
|
uint8_t *buffer = new uint8_t[10]();
|
||||||
int *data = new int;
|
int *data = new int;
|
||||||
*data = 10;
|
*data = 10;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
int *currentData = reinterpret_cast<int *>(data);
|
int *currentData = reinterpret_cast<int *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
@ -4115,7 +4115,7 @@ object->SetPrototype(vm_, prototype);
|
|||||||
|
|
||||||
### New
|
### New
|
||||||
|
|
||||||
Local<FunctionRef> FunctionRef::New(EcmaVM *vm, FunctionCallback nativeFunc, Deleter deleter, void *data, bool callNapi, size_t nativeBindingsize);
|
Local<FunctionRef> FunctionRef::New(EcmaVM *vm, FunctionCallback nativeFunc, NativePointerCallback deleter, void *data, bool callNapi, size_t nativeBindingsize);
|
||||||
|
|
||||||
创建一个新的函数对象。
|
创建一个新的函数对象。
|
||||||
|
|
||||||
@ -4125,7 +4125,7 @@ Local<FunctionRef> FunctionRef::New(EcmaVM *vm, FunctionCallback nativeFunc, Del
|
|||||||
| :---------------: | ---------------- | ---- | ------------------------------------------------------------ |
|
| :---------------: | ---------------- | ---- | ------------------------------------------------------------ |
|
||||||
| vm | const EcmaVM * | 是 | 指定虚拟机对象。 |
|
| vm | const EcmaVM * | 是 | 指定虚拟机对象。 |
|
||||||
| nativeFunc | FunctionCallback | 是 | 一个回调函数,当JS调用这个本地函数时,将调用这个回调函。 |
|
| nativeFunc | FunctionCallback | 是 | 一个回调函数,当JS调用这个本地函数时,将调用这个回调函。 |
|
||||||
| deleter | Deleter | 否 | 一个删除器函数,用于在不再需要`FunctionRef`对象时释放其资源。 |
|
| deleter | NativePointerCallback | 否 | 一个删除器函数,用于在不再需要`FunctionRef`对象时释放其资源。 |
|
||||||
| data | void * | 否 | 一个可选的指针,可以传递给回调函数或删除器函数。 |
|
| data | void * | 否 | 一个可选的指针,可以传递给回调函数或删除器函数。 |
|
||||||
| callNapi | bool | 否 | 一个布尔值,表示是否在创建`FunctionRef`对象时立即调用回调函数。如果为`true`,则在创建对象时立即调用回调函数;如果为`false`,则需要手动调用回调函数。 |
|
| callNapi | bool | 否 | 一个布尔值,表示是否在创建`FunctionRef`对象时立即调用回调函数。如果为`true`,则在创建对象时立即调用回调函数;如果为`false`,则需要手动调用回调函数。 |
|
||||||
| nativeBindingsize | size_t | 否 | 表示nativeFunc函数的大小,0表示未知大小。 |
|
| nativeBindingsize | size_t | 否 | 表示nativeFunc函数的大小,0表示未知大小。 |
|
||||||
@ -4149,7 +4149,7 @@ Local<FunctionRef> callback = FunctionRef::New(vm, FunCallback);
|
|||||||
|
|
||||||
### NewClassFunction
|
### NewClassFunction
|
||||||
|
|
||||||
Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, FunctionCallback nativeFunc, Deleter deleter, void *data, bool callNapi, size_t nativeBindingsize);
|
Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, FunctionCallback nativeFunc, NativePointerCallback deleter, void *data, bool callNapi, size_t nativeBindingsize);
|
||||||
|
|
||||||
创建一个新的类函数对象。
|
创建一个新的类函数对象。
|
||||||
|
|
||||||
@ -4159,7 +4159,7 @@ Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, FunctionCallback na
|
|||||||
| :---------------: | ---------------- | ---- | ------------------------------------------------------------ |
|
| :---------------: | ---------------- | ---- | ------------------------------------------------------------ |
|
||||||
| vm | const EcmaVM * | 是 | 指定虚拟机对象。 |
|
| vm | const EcmaVM * | 是 | 指定虚拟机对象。 |
|
||||||
| nativeFunc | FunctionCallback | 是 | 一个回调函数,当JS调用这个本地函数时,将调用这个回调函。 |
|
| nativeFunc | FunctionCallback | 是 | 一个回调函数,当JS调用这个本地函数时,将调用这个回调函。 |
|
||||||
| deleter | Deleter | 否 | 一个删除器函数,用于在不再需要`FunctionRef`对象时释放其资源。 |
|
| deleter | NativePointerCallback | 否 | 一个删除器函数,用于在不再需要`FunctionRef`对象时释放其资源。 |
|
||||||
| data | void * | 否 | 一个可选的指针,可以传递给回调函数或删除器函数。 |
|
| data | void * | 否 | 一个可选的指针,可以传递给回调函数或删除器函数。 |
|
||||||
| callNapi | bool | 否 | 一个布尔值,表示是否在创建`FunctionRef`对象时立即调用回调函数。如果为`true`,则在创建对象时立即调用回调函数;如果为`false`,则需要手动调用回调函数。 |
|
| callNapi | bool | 否 | 一个布尔值,表示是否在创建`FunctionRef`对象时立即调用回调函数。如果为`true`,则在创建对象时立即调用回调函数;如果为`false`,则需要手动调用回调函数。 |
|
||||||
| nativeBindingsize | size_t | 否 | 表示nativeFunc函数的大小,0表示未知大小。 |
|
| nativeBindingsize | size_t | 否 | 表示nativeFunc函数的大小,0表示未知大小。 |
|
||||||
@ -4178,7 +4178,7 @@ Local<JSValueRef> FunCallback(JsiRuntimeCallInfo *info)
|
|||||||
EscapeLocalScope scope(info->GetVM());
|
EscapeLocalScope scope(info->GetVM());
|
||||||
return scope.Escape(ArrayRef::New(info->GetVM(), info->GetArgsNumber()));
|
return scope.Escape(ArrayRef::New(info->GetVM(), info->GetArgsNumber()));
|
||||||
}
|
}
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
void *cb = reinterpret_cast<void *>(BuiltinsFunction::FunctionPrototypeInvokeSelf);
|
void *cb = reinterpret_cast<void *>(BuiltinsFunction::FunctionPrototypeInvokeSelf);
|
||||||
bool callNative = true;
|
bool callNative = true;
|
||||||
size_t nativeBindingSize = 15;
|
size_t nativeBindingSize = 15;
|
||||||
|
@ -78,7 +78,6 @@ struct AlignedPointer;
|
|||||||
}
|
}
|
||||||
} // namespace ecmascript
|
} // namespace ecmascript
|
||||||
|
|
||||||
using Deleter = void (*)(void *nativePointer, void *data);
|
|
||||||
using WeakRefClearCallBack = void (*)(void *);
|
using WeakRefClearCallBack = void (*)(void *);
|
||||||
using EcmaVM = ecmascript::EcmaVM;
|
using EcmaVM = ecmascript::EcmaVM;
|
||||||
using EcmaContext = ecmascript::EcmaContext;
|
using EcmaContext = ecmascript::EcmaContext;
|
||||||
|
@ -87,7 +87,6 @@ struct HmsMap {
|
|||||||
uint32_t sinceVersion;
|
uint32_t sinceVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Deleter = void (*)(void *nativePointer, void *data);
|
|
||||||
using WeakRefClearCallBack = void (*)(void *);
|
using WeakRefClearCallBack = void (*)(void *);
|
||||||
using WeakFinalizeTaskCallback = std::function<void()>;
|
using WeakFinalizeTaskCallback = std::function<void()>;
|
||||||
using EcmaVM = ecmascript::EcmaVM;
|
using EcmaVM = ecmascript::EcmaVM;
|
||||||
@ -620,7 +619,7 @@ private:
|
|||||||
bool hasConfigurable_ = false;
|
bool hasConfigurable_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
using NativePointerCallback = void (*)(void* value, void* hint);
|
using NativePointerCallback = void (*)(void *env, void* data, void* hint);
|
||||||
class ECMA_PUBLIC_API NativePointerRef : public JSValueRef {
|
class ECMA_PUBLIC_API NativePointerRef : public JSValueRef {
|
||||||
public:
|
public:
|
||||||
static Local<NativePointerRef> New(const EcmaVM *vm, void *nativePointer, size_t nativeBindingsize = 0);
|
static Local<NativePointerRef> New(const EcmaVM *vm, void *nativePointer, size_t nativeBindingsize = 0);
|
||||||
@ -714,27 +713,39 @@ public:
|
|||||||
SendablePropertiesInfo staticPropertiesInfo;
|
SendablePropertiesInfo staticPropertiesInfo;
|
||||||
SendablePropertiesInfo nonStaticPropertiesInfo;
|
SendablePropertiesInfo nonStaticPropertiesInfo;
|
||||||
};
|
};
|
||||||
static Local<FunctionRef> New(EcmaVM *vm, FunctionCallback nativeFunc, Deleter deleter = nullptr,
|
static Local<FunctionRef> New(EcmaVM *vm, FunctionCallback nativeFunc, NativePointerCallback deleter = nullptr,
|
||||||
void *data = nullptr, bool callNapi = false, size_t nativeBindingsize = 0);
|
void *data = nullptr, bool callNapi = false, size_t nativeBindingsize = 0);
|
||||||
static Local<FunctionRef> NewConcurrent(EcmaVM *vm, FunctionCallback nativeFunc, Deleter deleter = nullptr,
|
static Local<FunctionRef> NewConcurrent(EcmaVM *vm,
|
||||||
void *data = nullptr, bool callNapi = false, size_t nativeBindingsize = 0);
|
FunctionCallback nativeFunc,
|
||||||
static Local<FunctionRef> New(EcmaVM *vm, InternalFunctionCallback nativeFunc, Deleter deleter,
|
NativePointerCallback deleter = nullptr,
|
||||||
void *data = nullptr, bool callNapi = false, size_t nativeBindingsize = 0);
|
void *data = nullptr,
|
||||||
static Local<FunctionRef> NewConcurrent(EcmaVM *vm, InternalFunctionCallback nativeFunc, Deleter deleter,
|
bool callNapi = false,
|
||||||
|
size_t nativeBindingsize = 0);
|
||||||
|
static Local<FunctionRef> New(EcmaVM *vm, InternalFunctionCallback nativeFunc, NativePointerCallback deleter,
|
||||||
void *data = nullptr, bool callNapi = false, size_t nativeBindingsize = 0);
|
void *data = nullptr, bool callNapi = false, size_t nativeBindingsize = 0);
|
||||||
|
static Local<FunctionRef> NewConcurrent(EcmaVM *vm,
|
||||||
|
InternalFunctionCallback nativeFunc,
|
||||||
|
NativePointerCallback deleter,
|
||||||
|
void *data = nullptr,
|
||||||
|
bool callNapi = false,
|
||||||
|
size_t nativeBindingsize = 0);
|
||||||
static Local<FunctionRef> NewSendable(EcmaVM *vm,
|
static Local<FunctionRef> NewSendable(EcmaVM *vm,
|
||||||
InternalFunctionCallback nativeFunc,
|
InternalFunctionCallback nativeFunc,
|
||||||
Deleter deleter,
|
NativePointerCallback deleter,
|
||||||
void *data = nullptr,
|
void *data = nullptr,
|
||||||
bool callNapi = false,
|
bool callNapi = false,
|
||||||
size_t nativeBindingsize = 0);
|
size_t nativeBindingsize = 0);
|
||||||
static Local<FunctionRef> NewClassFunction(EcmaVM *vm, FunctionCallback nativeFunc, Deleter deleter,
|
static Local<FunctionRef> NewClassFunction(EcmaVM *vm, FunctionCallback nativeFunc, NativePointerCallback deleter,
|
||||||
void *data, bool callNapi = false, size_t nativeBindingsize = 0);
|
|
||||||
static Local<FunctionRef> NewClassFunction(EcmaVM *vm, InternalFunctionCallback nativeFunc, Deleter deleter,
|
|
||||||
void *data, bool callNapi = false, size_t nativeBindingsize = 0);
|
void *data, bool callNapi = false, size_t nativeBindingsize = 0);
|
||||||
|
static Local<FunctionRef> NewClassFunction(EcmaVM *vm,
|
||||||
|
InternalFunctionCallback nativeFunc,
|
||||||
|
NativePointerCallback deleter,
|
||||||
|
void *data,
|
||||||
|
bool callNapi = false,
|
||||||
|
size_t nativeBindingsize = 0);
|
||||||
static Local<FunctionRef> NewSendableClassFunction(const EcmaVM *vm,
|
static Local<FunctionRef> NewSendableClassFunction(const EcmaVM *vm,
|
||||||
InternalFunctionCallback nativeFunc,
|
InternalFunctionCallback nativeFunc,
|
||||||
Deleter deleter,
|
NativePointerCallback deleter,
|
||||||
void *data,
|
void *data,
|
||||||
Local<StringRef> name,
|
Local<StringRef> name,
|
||||||
SendablePropertiesInfos &infos,
|
SendablePropertiesInfos &infos,
|
||||||
@ -754,7 +765,7 @@ public:
|
|||||||
Local<StringRef> GetName(const EcmaVM *vm);
|
Local<StringRef> GetName(const EcmaVM *vm);
|
||||||
Local<StringRef> GetSourceCode(const EcmaVM *vm, int lineNumber);
|
Local<StringRef> GetSourceCode(const EcmaVM *vm, int lineNumber);
|
||||||
bool IsNative(const EcmaVM *vm);
|
bool IsNative(const EcmaVM *vm);
|
||||||
void SetData(const EcmaVM *vm, void *data, Deleter deleter = nullptr, bool callNapi = false);
|
void SetData(const EcmaVM *vm, void *data, NativePointerCallback deleter = nullptr, bool callNapi = false);
|
||||||
void* GetData(const EcmaVM *vm);
|
void* GetData(const EcmaVM *vm);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -908,8 +919,8 @@ public:
|
|||||||
class ECMA_PUBLIC_API ArrayBufferRef : public ObjectRef {
|
class ECMA_PUBLIC_API ArrayBufferRef : public ObjectRef {
|
||||||
public:
|
public:
|
||||||
static Local<ArrayBufferRef> New(const EcmaVM *vm, int32_t length);
|
static Local<ArrayBufferRef> New(const EcmaVM *vm, int32_t length);
|
||||||
static Local<ArrayBufferRef> New(const EcmaVM *vm, void *buffer, int32_t length, const Deleter &deleter,
|
static Local<ArrayBufferRef> New(const EcmaVM *vm, void *buffer, int32_t length,
|
||||||
void *data);
|
const NativePointerCallback &deleter, void *data);
|
||||||
|
|
||||||
int32_t ByteLength(const EcmaVM *vm);
|
int32_t ByteLength(const EcmaVM *vm);
|
||||||
void *GetBuffer();
|
void *GetBuffer();
|
||||||
@ -1150,7 +1161,7 @@ public:
|
|||||||
class ECMA_PUBLIC_API BufferRef : public ObjectRef {
|
class ECMA_PUBLIC_API BufferRef : public ObjectRef {
|
||||||
public:
|
public:
|
||||||
static Local<BufferRef> New(const EcmaVM *vm, int32_t length);
|
static Local<BufferRef> New(const EcmaVM *vm, int32_t length);
|
||||||
static Local<BufferRef> New(const EcmaVM *vm, void *buffer, int32_t length, const Deleter &deleter,
|
static Local<BufferRef> New(const EcmaVM *vm, void *buffer, int32_t length, const NativePointerCallback &deleter,
|
||||||
void *data);
|
void *data);
|
||||||
|
|
||||||
int32_t ByteLength(const EcmaVM *vm);
|
int32_t ByteLength(const EcmaVM *vm);
|
||||||
|
@ -1153,13 +1153,13 @@ Local<BufferRef> BufferRef::New(const EcmaVM *vm, int32_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<BufferRef> BufferRef::New(
|
Local<BufferRef> BufferRef::New(
|
||||||
const EcmaVM *vm, void *buffer, int32_t length, const Deleter &deleter, void *data)
|
const EcmaVM *vm, void *buffer, int32_t length, const NativePointerCallback &deleter, void *data)
|
||||||
{
|
{
|
||||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||||
ObjectFactory *factory = vm->GetFactory();
|
ObjectFactory *factory = vm->GetFactory();
|
||||||
JSHandle<JSArrayBuffer> arrayBuffer =
|
JSHandle<JSArrayBuffer> arrayBuffer =
|
||||||
factory->NewJSArrayBuffer(buffer, length, reinterpret_cast<ecmascript::DeleteEntryPoint>(deleter), data);
|
factory->NewJSArrayBuffer(buffer, length, reinterpret_cast<ecmascript::NativePointerCallback>(deleter), data);
|
||||||
|
|
||||||
JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
|
JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
|
||||||
JSHandle<JSFunction> current =
|
JSHandle<JSFunction> current =
|
||||||
@ -2138,13 +2138,13 @@ Local<ArrayBufferRef> ArrayBufferRef::New(const EcmaVM *vm, int32_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<ArrayBufferRef> ArrayBufferRef::New(
|
Local<ArrayBufferRef> ArrayBufferRef::New(
|
||||||
const EcmaVM *vm, void *buffer, int32_t length, const Deleter &deleter, void *data)
|
const EcmaVM *vm, void *buffer, int32_t length, const NativePointerCallback &deleter, void *data)
|
||||||
{
|
{
|
||||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||||
ObjectFactory *factory = vm->GetFactory();
|
ObjectFactory *factory = vm->GetFactory();
|
||||||
JSHandle<JSArrayBuffer> arrayBuffer =
|
JSHandle<JSArrayBuffer> arrayBuffer =
|
||||||
factory->NewJSArrayBuffer(buffer, length, reinterpret_cast<ecmascript::DeleteEntryPoint>(deleter), data);
|
factory->NewJSArrayBuffer(buffer, length, reinterpret_cast<ecmascript::NativePointerCallback>(deleter), data);
|
||||||
return JSNApiHelper::ToLocal<ArrayBufferRef>(JSHandle<JSTaggedValue>(arrayBuffer));
|
return JSNApiHelper::ToLocal<ArrayBufferRef>(JSHandle<JSTaggedValue>(arrayBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2258,7 +2258,7 @@ Local<ArrayBufferRef> TypedArrayRef::GetArrayBuffer(const EcmaVM *vm)
|
|||||||
|
|
||||||
// ----------------------------------- FunctionRef --------------------------------------
|
// ----------------------------------- FunctionRef --------------------------------------
|
||||||
Local<FunctionRef> FunctionRef::New(EcmaVM *vm, FunctionCallback nativeFunc,
|
Local<FunctionRef> FunctionRef::New(EcmaVM *vm, FunctionCallback nativeFunc,
|
||||||
Deleter deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
NativePointerCallback deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
||||||
{
|
{
|
||||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||||
@ -2271,7 +2271,7 @@ Local<FunctionRef> FunctionRef::New(EcmaVM *vm, FunctionCallback nativeFunc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<FunctionRef> FunctionRef::NewConcurrent(EcmaVM *vm, FunctionCallback nativeFunc,
|
Local<FunctionRef> FunctionRef::NewConcurrent(EcmaVM *vm, FunctionCallback nativeFunc,
|
||||||
Deleter deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
NativePointerCallback deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
||||||
{
|
{
|
||||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||||
ObjectFactory *factory = vm->GetFactory();
|
ObjectFactory *factory = vm->GetFactory();
|
||||||
@ -2284,7 +2284,7 @@ Local<FunctionRef> FunctionRef::NewConcurrent(EcmaVM *vm, FunctionCallback nativ
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<FunctionRef> FunctionRef::New(EcmaVM *vm, InternalFunctionCallback nativeFunc,
|
Local<FunctionRef> FunctionRef::New(EcmaVM *vm, InternalFunctionCallback nativeFunc,
|
||||||
Deleter deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
NativePointerCallback deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
||||||
{
|
{
|
||||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||||
@ -2298,7 +2298,7 @@ Local<FunctionRef> FunctionRef::New(EcmaVM *vm, InternalFunctionCallback nativeF
|
|||||||
|
|
||||||
Local<FunctionRef> FunctionRef::NewSendable(EcmaVM *vm,
|
Local<FunctionRef> FunctionRef::NewSendable(EcmaVM *vm,
|
||||||
InternalFunctionCallback nativeFunc,
|
InternalFunctionCallback nativeFunc,
|
||||||
Deleter deleter,
|
NativePointerCallback deleter,
|
||||||
void *data,
|
void *data,
|
||||||
bool callNapi,
|
bool callNapi,
|
||||||
size_t nativeBindingsize)
|
size_t nativeBindingsize)
|
||||||
@ -2314,7 +2314,7 @@ Local<FunctionRef> FunctionRef::NewSendable(EcmaVM *vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<FunctionRef> FunctionRef::NewConcurrent(EcmaVM *vm, InternalFunctionCallback nativeFunc,
|
Local<FunctionRef> FunctionRef::NewConcurrent(EcmaVM *vm, InternalFunctionCallback nativeFunc,
|
||||||
Deleter deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
NativePointerCallback deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
||||||
{
|
{
|
||||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||||
ObjectFactory *factory = vm->GetFactory();
|
ObjectFactory *factory = vm->GetFactory();
|
||||||
@ -2346,7 +2346,7 @@ static void InitClassFunction(EcmaVM *vm, JSHandle<JSFunction> &func, bool callN
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, FunctionCallback nativeFunc,
|
Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, FunctionCallback nativeFunc,
|
||||||
Deleter deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
NativePointerCallback deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
||||||
{
|
{
|
||||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||||
@ -2364,7 +2364,7 @@ Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, FunctionCallback na
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, InternalFunctionCallback nativeFunc,
|
Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, InternalFunctionCallback nativeFunc,
|
||||||
Deleter deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
NativePointerCallback deleter, void *data, bool callNapi, size_t nativeBindingsize)
|
||||||
{
|
{
|
||||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||||
@ -2383,7 +2383,7 @@ Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, InternalFunctionCal
|
|||||||
|
|
||||||
Local<FunctionRef> FunctionRef::NewSendableClassFunction(const EcmaVM *vm,
|
Local<FunctionRef> FunctionRef::NewSendableClassFunction(const EcmaVM *vm,
|
||||||
InternalFunctionCallback nativeFunc,
|
InternalFunctionCallback nativeFunc,
|
||||||
Deleter deleter,
|
NativePointerCallback deleter,
|
||||||
void *data,
|
void *data,
|
||||||
Local<StringRef> name,
|
Local<StringRef> name,
|
||||||
SendablePropertiesInfos &infos,
|
SendablePropertiesInfos &infos,
|
||||||
@ -2670,7 +2670,7 @@ bool FunctionRef::IsNative(const EcmaVM *vm)
|
|||||||
return method->IsNativeWithCallField();
|
return method->IsNativeWithCallField();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionRef::SetData(const EcmaVM *vm, void *data, Deleter deleter, [[maybe_unused]] bool callNapi)
|
void FunctionRef::SetData(const EcmaVM *vm, void *data, NativePointerCallback deleter, [[maybe_unused]] bool callNapi)
|
||||||
{
|
{
|
||||||
CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
|
CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
|
||||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||||
@ -3026,12 +3026,14 @@ void JSNApi::AllowCrossThreadExecution(EcmaVM *vm)
|
|||||||
|
|
||||||
void* JSNApi::GetEnv(EcmaVM *vm)
|
void* JSNApi::GetEnv(EcmaVM *vm)
|
||||||
{
|
{
|
||||||
return vm->GetEnv();
|
JSThread *thread = vm->GetJSThread();
|
||||||
|
return thread->GetEnv();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSNApi::SetEnv(EcmaVM *vm, void *env)
|
void JSNApi::SetEnv(EcmaVM *vm, void *env)
|
||||||
{
|
{
|
||||||
vm->SetEnv(env);
|
JSThread *thread = vm->GetJSThread();
|
||||||
|
thread->SetEnv(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSNApi::SynchronizVMInfo(EcmaVM *vm, const EcmaVM *hostVM)
|
void JSNApi::SynchronizVMInfo(EcmaVM *vm, const EcmaVM *hostVM)
|
||||||
|
@ -380,7 +380,7 @@ HWTEST_F_L0(JSNApiSplTest, JSValueRef_IsFunction_True)
|
|||||||
{
|
{
|
||||||
LocalScope scope(vm_);
|
LocalScope scope(vm_);
|
||||||
CalculateForTime();
|
CalculateForTime();
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
void *cb = reinterpret_cast<void *>(BuiltinsFunction::FunctionPrototypeInvokeSelf);
|
void *cb = reinterpret_cast<void *>(BuiltinsFunction::FunctionPrototypeInvokeSelf);
|
||||||
bool callNative = true;
|
bool callNative = true;
|
||||||
size_t nativeBindingSize = 15;
|
size_t nativeBindingSize = 15;
|
||||||
@ -529,7 +529,7 @@ HWTEST_F_L0(JSNApiSplTest, JSValueRef_IsArrayBuffer)
|
|||||||
const int32_t length = 15;
|
const int32_t length = 15;
|
||||||
Data *data = new Data();
|
Data *data = new Data();
|
||||||
data->length = length;
|
data->length = length;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
Data *currentData = reinterpret_cast<Data *>(data);
|
Data *currentData = reinterpret_cast<Data *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
@ -554,7 +554,7 @@ HWTEST_F_L0(JSNApiSplTest, BufferRef_New1)
|
|||||||
int32_t length;
|
int32_t length;
|
||||||
};
|
};
|
||||||
const int32_t length = 15;
|
const int32_t length = 15;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
Data *currentData = reinterpret_cast<Data *>(data);
|
Data *currentData = reinterpret_cast<Data *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
@ -850,7 +850,7 @@ HWTEST_F_L0(JSNApiSplTest, ArrayBufferRef_New1)
|
|||||||
int32_t length;
|
int32_t length;
|
||||||
};
|
};
|
||||||
const int32_t length = 15;
|
const int32_t length = 15;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
Data *currentData = reinterpret_cast<Data *>(data);
|
Data *currentData = reinterpret_cast<Data *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
@ -6335,7 +6335,7 @@ HWTEST_F_L0(JSNApiSplTest, JSValueRef_InitForConcurrentFunction)
|
|||||||
{
|
{
|
||||||
LocalScope scope(vm_);
|
LocalScope scope(vm_);
|
||||||
CalculateForTime();
|
CalculateForTime();
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
void *cb = reinterpret_cast<void *>(BuiltinsFunction::FunctionPrototypeInvokeSelf);
|
void *cb = reinterpret_cast<void *>(BuiltinsFunction::FunctionPrototypeInvokeSelf);
|
||||||
bool callNative = true;
|
bool callNative = true;
|
||||||
size_t nativeBindingsize = 15;
|
size_t nativeBindingsize = 15;
|
||||||
|
@ -484,7 +484,7 @@ HWTEST_F_L0(JSNApiTests, CreateNativeObject)
|
|||||||
size_t nativeBindingSize = 7 * sizeof(void *); // 7 : params num
|
size_t nativeBindingSize = 7 * sizeof(void *); // 7 : params num
|
||||||
Local<NativePointerRef> nativeInfo = NativePointerRef::New(
|
Local<NativePointerRef> nativeInfo = NativePointerRef::New(
|
||||||
vm_, reinterpret_cast<void *>(info),
|
vm_, reinterpret_cast<void *>(info),
|
||||||
[](void *data, [[maybe_unused]] void *info) {
|
[]([[maybe_unused]] void *env, void *data, [[maybe_unused]] void *info) {
|
||||||
auto externalInfo = reinterpret_cast<panda::JSNApi::NativeBindingInfo *>(data);
|
auto externalInfo = reinterpret_cast<panda::JSNApi::NativeBindingInfo *>(data);
|
||||||
delete externalInfo;
|
delete externalInfo;
|
||||||
},
|
},
|
||||||
@ -572,7 +572,7 @@ HWTEST_F_L0(JSNApiTests, GetProtoType)
|
|||||||
size_t nativeBindingSize = 7 * sizeof(void *); // 7 : params num
|
size_t nativeBindingSize = 7 * sizeof(void *); // 7 : params num
|
||||||
Local<NativePointerRef> nativeInfo = NativePointerRef::New(
|
Local<NativePointerRef> nativeInfo = NativePointerRef::New(
|
||||||
vm_, reinterpret_cast<void *>(info),
|
vm_, reinterpret_cast<void *>(info),
|
||||||
[](void *data, [[maybe_unused]] void *info) {
|
[]([[maybe_unused]] void *env, void *data, [[maybe_unused]] void *info) {
|
||||||
auto externalInfo = reinterpret_cast<panda::JSNApi::NativeBindingInfo *>(data);
|
auto externalInfo = reinterpret_cast<panda::JSNApi::NativeBindingInfo *>(data);
|
||||||
delete externalInfo;
|
delete externalInfo;
|
||||||
},
|
},
|
||||||
@ -718,7 +718,7 @@ HWTEST_F_L0(JSNApiTests, ArrayBufferWithBuffer)
|
|||||||
const int32_t length = 15;
|
const int32_t length = 15;
|
||||||
Data *data = new Data();
|
Data *data = new Data();
|
||||||
data->length = length;
|
data->length = length;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
Data *currentData = reinterpret_cast<Data *>(data);
|
Data *currentData = reinterpret_cast<Data *>(data);
|
||||||
ASSERT_EQ(currentData->length, 15); // 5 : size of arguments
|
ASSERT_EQ(currentData->length, 15); // 5 : size of arguments
|
||||||
@ -1655,7 +1655,7 @@ HWTEST_F_L0(JSNApiTests, ObjectRef_SetNativePointerFieldCount_GetNativePointerFi
|
|||||||
HWTEST_F_L0(JSNApiTests, FunctionRef_GetFunctionPrototype_SetName_GetName)
|
HWTEST_F_L0(JSNApiTests, FunctionRef_GetFunctionPrototype_SetName_GetName)
|
||||||
{
|
{
|
||||||
LocalScope scope(vm_);
|
LocalScope scope(vm_);
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
void *cb = reinterpret_cast<void *>(BuiltinsFunction::FunctionPrototypeInvokeSelf);
|
void *cb = reinterpret_cast<void *>(BuiltinsFunction::FunctionPrototypeInvokeSelf);
|
||||||
bool callNative = true;
|
bool callNative = true;
|
||||||
size_t nativeBindingsize = 15;
|
size_t nativeBindingsize = 15;
|
||||||
|
@ -309,7 +309,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_NativePointerRef)
|
|||||||
GTEST_LOG_(INFO) << "sample_NativePointer adress: " << nativePointerTestClass;
|
GTEST_LOG_(INFO) << "sample_NativePointer adress: " << nativePointerTestClass;
|
||||||
Local<NativePointerRef> nativePoint = NativePointerRef::New(
|
Local<NativePointerRef> nativePoint = NativePointerRef::New(
|
||||||
vm_, nativePointerTestClass,
|
vm_, nativePointerTestClass,
|
||||||
[](void *value, void *hint) {
|
[](void *env, void *value, void *hint) {
|
||||||
GTEST_LOG_(INFO) << "NativePointerCb value : " << value;
|
GTEST_LOG_(INFO) << "NativePointerCb value : " << value;
|
||||||
GTEST_LOG_(INFO) << "NativePointerCb hint : " << hint;
|
GTEST_LOG_(INFO) << "NativePointerCb hint : " << hint;
|
||||||
NativePointerTestClass *ptr = static_cast<NativePointerTestClass *>(value);
|
NativePointerTestClass *ptr = static_cast<NativePointerTestClass *>(value);
|
||||||
@ -1085,7 +1085,7 @@ Local<FunctionRef> Greeter::NewClassFunction(EcmaVM *vm)
|
|||||||
thisRef->Set(vm, StringRef::NewFromUtf8(vm, "greeting"), greet);
|
thisRef->Set(vm, StringRef::NewFromUtf8(vm, "greeting"), greet);
|
||||||
return thisRef;
|
return thisRef;
|
||||||
},
|
},
|
||||||
[](void *nativePointer, void *data) {
|
[](void *env, void *nativePointer, void *data) {
|
||||||
GTEST_LOG_(INFO) << "NewClassFunction, nativePointer is " << nativePointer;
|
GTEST_LOG_(INFO) << "NewClassFunction, nativePointer is " << nativePointer;
|
||||||
Tag *t = static_cast<Tag *>(data);
|
Tag *t = static_cast<Tag *>(data);
|
||||||
delete t;
|
delete t;
|
||||||
@ -2148,7 +2148,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_ArrayBufferWithBuffer_New_Detach)
|
|||||||
const int32_t length = 5; // arraybuffer length = 5
|
const int32_t length = 5; // arraybuffer length = 5
|
||||||
Data *data = new Data();
|
Data *data = new Data();
|
||||||
data->length = length;
|
data->length = length;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
Data *currentData = reinterpret_cast<Data *>(data);
|
Data *currentData = reinterpret_cast<Data *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
@ -2183,7 +2183,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_BufferWithBuffer_New_GetBuffer)
|
|||||||
const int32_t length = 5; // buffer length = 5
|
const int32_t length = 5; // buffer length = 5
|
||||||
Data *data = new Data();
|
Data *data = new Data();
|
||||||
data->length = length;
|
data->length = length;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
Data *currentData = reinterpret_cast<Data *>(data);
|
Data *currentData = reinterpret_cast<Data *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
|
@ -291,7 +291,7 @@ HWTEST_F_L0(JSNApiTests, BufferRef_New01_ByteLength_GetBuffer_BufferToStringCall
|
|||||||
int32_t length;
|
int32_t length;
|
||||||
};
|
};
|
||||||
const int32_t length = 15;
|
const int32_t length = 15;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
Data *currentData = reinterpret_cast<Data *>(data);
|
Data *currentData = reinterpret_cast<Data *>(data);
|
||||||
delete currentData;
|
delete currentData;
|
||||||
@ -524,7 +524,7 @@ HWTEST_F_L0(JSNApiTests, New2)
|
|||||||
const int32_t length = 15;
|
const int32_t length = 15;
|
||||||
Data *data = new Data();
|
Data *data = new Data();
|
||||||
data->length = length;
|
data->length = length;
|
||||||
Deleter deleter = [](void *buffer, void *data) -> void {
|
NativePointerCallback deleter = [](void *env, void *buffer, void *data) -> void {
|
||||||
delete[] reinterpret_cast<uint8_t *>(buffer);
|
delete[] reinterpret_cast<uint8_t *>(buffer);
|
||||||
Data *currentData = reinterpret_cast<Data *>(data);
|
Data *currentData = reinterpret_cast<Data *>(data);
|
||||||
ASSERT_EQ(currentData->length, 15); // 5 : size of arguments
|
ASSERT_EQ(currentData->length, 15); // 5 : size of arguments
|
||||||
|
@ -93,7 +93,7 @@ EcmaString *ObjectFactory::AllocTreeStringObject()
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSHandle<JSNativePointer> ObjectFactory::NewJSNativePointer(void *externalPointer,
|
JSHandle<JSNativePointer> ObjectFactory::NewJSNativePointer(void *externalPointer,
|
||||||
const DeleteEntryPoint &callBack,
|
const NativePointerCallback &callBack,
|
||||||
void *data,
|
void *data,
|
||||||
bool nonMovable,
|
bool nonMovable,
|
||||||
size_t nativeBindingsize,
|
size_t nativeBindingsize,
|
||||||
@ -140,14 +140,14 @@ LexicalEnv *ObjectFactory::InlineNewLexicalEnv(int numSlots)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename S>
|
template<typename T, typename S>
|
||||||
void ObjectFactory::NewJSIntlIcuData(const JSHandle<T> &obj, const S &icu, const DeleteEntryPoint &callback)
|
void ObjectFactory::NewJSIntlIcuData(const JSHandle<T> &obj, const S &icu, const NativePointerCallback &callback)
|
||||||
{
|
{
|
||||||
S *icuPoint = vm_->GetNativeAreaAllocator()->New<S>(icu);
|
S *icuPoint = vm_->GetNativeAreaAllocator()->New<S>(icu);
|
||||||
ASSERT(icuPoint != nullptr);
|
ASSERT(icuPoint != nullptr);
|
||||||
JSTaggedValue data = obj->GetIcuField();
|
JSTaggedValue data = obj->GetIcuField();
|
||||||
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
if (data.IsHeapObject() && data.IsJSNativePointer()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(icuPoint);
|
native->ResetExternalPointer(thread_, icuPoint);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = NewJSNativePointer(icuPoint, callback, vm_);
|
JSHandle<JSNativePointer> pointer = NewJSNativePointer(icuPoint, callback, vm_);
|
||||||
|
@ -259,7 +259,7 @@ void ObjectFactory::NewJSArrayBufferData(const JSHandle<JSArrayBuffer> &array, i
|
|||||||
LOG_FULL(FATAL) << "memset_s failed";
|
LOG_FULL(FATAL) << "memset_s failed";
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
pointer->ResetExternalPointer(newData);
|
pointer->ResetExternalPointer(thread_, newData);
|
||||||
vm_->GetNativeAreaAllocator()->ModifyNativeSizeStats(pointer->GetBindingSize(), size,
|
vm_->GetNativeAreaAllocator()->ModifyNativeSizeStats(pointer->GetBindingSize(), size,
|
||||||
NativeFlag::ARRAY_BUFFER);
|
NativeFlag::ARRAY_BUFFER);
|
||||||
return;
|
return;
|
||||||
@ -294,7 +294,7 @@ void ObjectFactory::NewJSSendableArrayBufferData(const JSHandle<JSSendableArrayB
|
|||||||
LOG_FULL(FATAL) << "memset_s failed";
|
LOG_FULL(FATAL) << "memset_s failed";
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
pointer->ResetExternalPointer(newData);
|
pointer->ResetExternalPointer(thread_, newData);
|
||||||
nativeAreaAllocator->ModifyNativeSizeStats(pointer->GetBindingSize(), size,
|
nativeAreaAllocator->ModifyNativeSizeStats(pointer->GetBindingSize(), size,
|
||||||
NativeFlag::ARRAY_BUFFER);
|
NativeFlag::ARRAY_BUFFER);
|
||||||
return;
|
return;
|
||||||
@ -368,8 +368,8 @@ JSHandle<JSArrayBuffer> ObjectFactory::NewJSArrayBuffer(int32_t length)
|
|||||||
return arrayBuffer;
|
return arrayBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSHandle<JSArrayBuffer> ObjectFactory::NewJSArrayBuffer(void *buffer, int32_t length, const DeleteEntryPoint &deleter,
|
JSHandle<JSArrayBuffer> ObjectFactory::NewJSArrayBuffer(void *buffer, int32_t length,
|
||||||
void *data, bool share)
|
const NativePointerCallback &deleter, void *data, bool share)
|
||||||
{
|
{
|
||||||
JSHandle<GlobalEnv> env = vm_->GetGlobalEnv();
|
JSHandle<GlobalEnv> env = vm_->GetGlobalEnv();
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ void ObjectFactory::NewJSRegExpByteCodeData(const JSHandle<JSRegExp> ®exp, vo
|
|||||||
JSTaggedValue data = regexp->GetByteCodeBuffer();
|
JSTaggedValue data = regexp->GetByteCodeBuffer();
|
||||||
if (!data.IsUndefined()) {
|
if (!data.IsUndefined()) {
|
||||||
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject());
|
||||||
native->ResetExternalPointer(newBuffer);
|
native->ResetExternalPointer(thread_, newBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSHandle<JSNativePointer> pointer = NewJSNativePointer(newBuffer, NativeAreaAllocator::FreeBufferFunc,
|
JSHandle<JSNativePointer> pointer = NewJSNativePointer(newBuffer, NativeAreaAllocator::FreeBufferFunc,
|
||||||
|
@ -502,8 +502,8 @@ public:
|
|||||||
|
|
||||||
JSHandle<JSArrayBuffer> NewJSArrayBuffer(int32_t length);
|
JSHandle<JSArrayBuffer> NewJSArrayBuffer(int32_t length);
|
||||||
|
|
||||||
JSHandle<JSArrayBuffer> NewJSArrayBuffer(void *buffer, int32_t length, const DeleteEntryPoint &deleter, void *data,
|
JSHandle<JSArrayBuffer> NewJSArrayBuffer(void *buffer, int32_t length, const NativePointerCallback &deleter,
|
||||||
bool share = false);
|
void *data, bool share = false);
|
||||||
|
|
||||||
JSHandle<JSDataView> NewJSDataView(JSHandle<JSArrayBuffer> buffer, uint32_t offset, uint32_t length);
|
JSHandle<JSDataView> NewJSDataView(JSHandle<JSArrayBuffer> buffer, uint32_t offset, uint32_t length);
|
||||||
|
|
||||||
@ -516,12 +516,12 @@ public:
|
|||||||
void NewJSRegExpByteCodeData(const JSHandle<JSRegExp> ®exp, void *buffer, size_t size);
|
void NewJSRegExpByteCodeData(const JSHandle<JSRegExp> ®exp, void *buffer, size_t size);
|
||||||
|
|
||||||
template<typename T, typename S>
|
template<typename T, typename S>
|
||||||
inline void NewJSIntlIcuData(const JSHandle<T> &obj, const S &icu, const DeleteEntryPoint &callback);
|
inline void NewJSIntlIcuData(const JSHandle<T> &obj, const S &icu, const NativePointerCallback &callback);
|
||||||
|
|
||||||
EcmaString *PUBLIC_API InternString(const JSHandle<JSTaggedValue> &key);
|
EcmaString *PUBLIC_API InternString(const JSHandle<JSTaggedValue> &key);
|
||||||
|
|
||||||
inline JSHandle<JSNativePointer> NewJSNativePointer(void *externalPointer,
|
inline JSHandle<JSNativePointer> NewJSNativePointer(void *externalPointer,
|
||||||
const DeleteEntryPoint &callBack = nullptr,
|
const NativePointerCallback &callBack = nullptr,
|
||||||
void *data = nullptr,
|
void *data = nullptr,
|
||||||
bool nonMovable = false,
|
bool nonMovable = false,
|
||||||
size_t nativeBindingsize = 0,
|
size_t nativeBindingsize = 0,
|
||||||
@ -830,7 +830,7 @@ public:
|
|||||||
const JSHandle<JSTaggedValue> &prototype, bool isAccessor = true);
|
const JSHandle<JSTaggedValue> &prototype, bool isAccessor = true);
|
||||||
|
|
||||||
JSHandle<JSNativePointer> NewSJSNativePointer(void *externalPointer,
|
JSHandle<JSNativePointer> NewSJSNativePointer(void *externalPointer,
|
||||||
const DeleteEntryPoint &callBack,
|
const NativePointerCallback &callBack,
|
||||||
void *data = nullptr,
|
void *data = nullptr,
|
||||||
bool nonMovable = false,
|
bool nonMovable = false,
|
||||||
size_t nativeBindingsize = 0,
|
size_t nativeBindingsize = 0,
|
||||||
|
@ -344,7 +344,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto manager = JSSharedMemoryManager::GetInstance();
|
auto manager = JSSharedMemoryManager::GetInstance();
|
||||||
for (auto iter = sharedArrayBufferSet_.begin(); iter != sharedArrayBufferSet_.end(); iter++) {
|
for (auto iter = sharedArrayBufferSet_.begin(); iter != sharedArrayBufferSet_.end(); iter++) {
|
||||||
JSSharedMemoryManager::RemoveSharedMemory(reinterpret_cast<void *>(*iter), manager);
|
JSSharedMemoryManager::RemoveSharedMemory(thread_->GetEnv(), reinterpret_cast<void *>(*iter), manager);
|
||||||
}
|
}
|
||||||
sharedArrayBufferSet_.clear();
|
sharedArrayBufferSet_.clear();
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ void JSSharedMemoryManager::FreeBuffer(void *mem)
|
|||||||
free(mem);
|
free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSSharedMemoryManager::RemoveSharedMemory(void *pointer, void *data)
|
void JSSharedMemoryManager::RemoveSharedMemory([[maybe_unused]] void *env, void *pointer, void *data)
|
||||||
{
|
{
|
||||||
if (pointer == nullptr || data == nullptr) {
|
if (pointer == nullptr || data == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
return &jsSharedMemoryManager;
|
return &jsSharedMemoryManager;
|
||||||
}
|
}
|
||||||
bool CreateOrLoad(void **pointer, size_t size);
|
bool CreateOrLoad(void **pointer, size_t size);
|
||||||
static void RemoveSharedMemory(void *pointer, void *data);
|
static void RemoveSharedMemory(void *env, void *pointer, void *data);
|
||||||
private:
|
private:
|
||||||
JSSharedMemoryManager() = default;
|
JSSharedMemoryManager() = default;
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ JSHandle<MutantTaggedArray> ObjectFactory::NewSEmptyMutantArray()
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSHandle<JSNativePointer> ObjectFactory::NewSJSNativePointer(void *externalPointer,
|
JSHandle<JSNativePointer> ObjectFactory::NewSJSNativePointer(void *externalPointer,
|
||||||
const DeleteEntryPoint &callBack,
|
const NativePointerCallback &callBack,
|
||||||
void *data,
|
void *data,
|
||||||
bool nonMovable,
|
bool nonMovable,
|
||||||
size_t nativeBindingsize,
|
size_t nativeBindingsize,
|
||||||
|
@ -203,7 +203,7 @@ HWTEST_F_L0(GCTest, CallbackTask)
|
|||||||
void *externalPointer = malloc(10);
|
void *externalPointer = malloc(10);
|
||||||
[[maybe_unused]] JSHandle<JSNativePointer> nativePointer
|
[[maybe_unused]] JSHandle<JSNativePointer> nativePointer
|
||||||
= factory->NewJSNativePointer(externalPointer,
|
= factory->NewJSNativePointer(externalPointer,
|
||||||
[](void* pointer, [[maybe_unused]] void* data) {
|
[](void *env, void* pointer, [[maybe_unused]] void* data) {
|
||||||
if (pointer != nullptr) {
|
if (pointer != nullptr) {
|
||||||
free(pointer);
|
free(pointer);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ void ArrayBufferRefNewFuzzTest(const uint8_t* data, size_t size)
|
|||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||||
JSNApi::DestroyJSVM(vm);
|
JSNApi::DestroyJSVM(vm);
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ void ArrayBufferRef_New_IsDetach_Detach_ByteLength_GetBuffer_FuzzTest(const uint
|
|||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||||
arrayBuffer->IsDetach();
|
arrayBuffer->IsDetach();
|
||||||
arrayBuffer->Detach(vm);
|
arrayBuffer->Detach(vm);
|
||||||
|
@ -43,7 +43,7 @@ void BufferRefMultiParamNewFuzzTest(const uint8_t *data, size_t size)
|
|||||||
RuntimeOption option;
|
RuntimeOption option;
|
||||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
BufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
BufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||||
JSNApi::DestroyJSVM(vm);
|
JSNApi::DestroyJSVM(vm);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ void EscapeLocalScopeFuzzTest(const uint8_t *data, size_t size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FunctionCallback nativeFunc = FuncRefNewCFCallbackForTest;
|
FunctionCallback nativeFunc = FuncRefNewCFCallbackForTest;
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
FunctionRef::NewClassFunction(vm, nativeFunc, deleter, (void *)(data + size));
|
FunctionRef::NewClassFunction(vm, nativeFunc, deleter, (void *)(data + size));
|
||||||
JSNApi::DestroyJSVM(vm);
|
JSNApi::DestroyJSVM(vm);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace OHOS {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FunctionCallback nativeFunc = FuncRefCallCallbackForTest;
|
FunctionCallback nativeFunc = FuncRefCallCallbackForTest;
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
||||||
const int32_t argvLen = 3;
|
const int32_t argvLen = 3;
|
||||||
Local<JSValueRef> thisObj(JSValueRef::Undefined(vm));
|
Local<JSValueRef> thisObj(JSValueRef::Undefined(vm));
|
||||||
|
@ -37,7 +37,7 @@ namespace OHOS {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FunctionCallback nativeFunc = FuncRefConCallbackForTest;
|
FunctionCallback nativeFunc = FuncRefConCallbackForTest;
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
||||||
Local<JSValueRef> argv[1];
|
Local<JSValueRef> argv[1];
|
||||||
argv[0] = NumberRef::New(vm, 1.3); // 1.3 : test case of input
|
argv[0] = NumberRef::New(vm, 1.3); // 1.3 : test case of input
|
||||||
|
@ -37,7 +37,7 @@ void FunctionRefGetFunctionPrototypeFuzzTest(const uint8_t *data, size_t size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FunctionCallback nativeFunc = FuncRefConCallbackForTest;
|
FunctionCallback nativeFunc = FuncRefConCallbackForTest;
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
||||||
func->GetFunctionPrototype(vm);
|
func->GetFunctionPrototype(vm);
|
||||||
JSNApi::DestroyJSVM(vm);
|
JSNApi::DestroyJSVM(vm);
|
||||||
|
@ -37,7 +37,7 @@ void FunctionRefSetNameFuzzTest(const uint8_t *data, size_t size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FunctionCallback nativeFunc = FuncRefConCallbackForTest;
|
FunctionCallback nativeFunc = FuncRefConCallbackForTest;
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
||||||
Local<StringRef> name = StringRef::NewFromUtf8(vm, (char *)data, (int)size);
|
Local<StringRef> name = StringRef::NewFromUtf8(vm, (char *)data, (int)size);
|
||||||
func->SetName(vm, name);
|
func->SetName(vm, name);
|
||||||
@ -54,7 +54,7 @@ void FunctionRefGetNameFuzzTest(const uint8_t *data, size_t size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FunctionCallback nativeFunc = FuncRefConCallbackForTest;
|
FunctionCallback nativeFunc = FuncRefConCallbackForTest;
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
||||||
Local<StringRef> name = StringRef::NewFromUtf8(vm, (char *)data, (int)size);
|
Local<StringRef> name = StringRef::NewFromUtf8(vm, (char *)data, (int)size);
|
||||||
func->SetName(vm, name);
|
func->SetName(vm, name);
|
||||||
|
@ -36,7 +36,7 @@ namespace OHOS {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FunctionCallback nativeFunc = FuncRefNewCallbackForTest;
|
FunctionCallback nativeFunc = FuncRefNewCallbackForTest;
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
||||||
JSNApi::DestroyJSVM(vm);
|
JSNApi::DestroyJSVM(vm);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace OHOS {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FunctionCallback nativeFunc = FuncRefNewCFCallbackForTest;
|
FunctionCallback nativeFunc = FuncRefNewCFCallbackForTest;
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
FunctionRef::NewClassFunction(vm, nativeFunc, deleter, (void *)(data + size));
|
FunctionRef::NewClassFunction(vm, nativeFunc, deleter, (void *)(data + size));
|
||||||
JSNApi::DestroyJSVM(vm);
|
JSNApi::DestroyJSVM(vm);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ void JSValueRefIsFunctionValueFuzzTest(const uint8_t *data, size_t size)
|
|||||||
std::cout << "illegal input!";
|
std::cout << "illegal input!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
FunctionCallback nativeFunc = FunCallback;
|
FunctionCallback nativeFunc = FunCallback;
|
||||||
Local<FunctionRef> obj(FunctionRef::NewClassFunction(vm, nativeFunc, deleter, (void *)(data + size)));
|
Local<FunctionRef> obj(FunctionRef::NewClassFunction(vm, nativeFunc, deleter, (void *)(data + size)));
|
||||||
(void)obj->IsFunction();
|
(void)obj->IsFunction();
|
||||||
|
@ -30,7 +30,7 @@ void IsInt8ArrayFuzztest(const uint8_t *data, size_t size)
|
|||||||
LOG_ECMA(ERROR) << "illegal input!";
|
LOG_ECMA(ERROR) << "illegal input!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||||
Local<JSValueRef> typedArray = Int8ArrayRef::New(vm, arrayBuffer, 0, (int32_t)size);
|
Local<JSValueRef> typedArray = Int8ArrayRef::New(vm, arrayBuffer, 0, (int32_t)size);
|
||||||
typedArray->IsInt8Array();
|
typedArray->IsInt8Array();
|
||||||
@ -46,7 +46,7 @@ void IsUint8ArrayFuzztest(const uint8_t *data, size_t size)
|
|||||||
LOG_ECMA(ERROR) << "illegal input!";
|
LOG_ECMA(ERROR) << "illegal input!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||||
Local<JSValueRef> typedArray = Uint8ArrayRef::New(vm, arrayBuffer, 0, (int32_t)size);
|
Local<JSValueRef> typedArray = Uint8ArrayRef::New(vm, arrayBuffer, 0, (int32_t)size);
|
||||||
typedArray->IsUint8Array();
|
typedArray->IsUint8Array();
|
||||||
@ -62,7 +62,7 @@ void IsUint8ClampedArrayFuzztest(const uint8_t *data, size_t size)
|
|||||||
LOG_ECMA(ERROR) << "illegal input!";
|
LOG_ECMA(ERROR) << "illegal input!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||||
Local<JSValueRef> typedArray = Uint8ClampedArrayRef::New(vm, arrayBuffer, 0, (int32_t)size);
|
Local<JSValueRef> typedArray = Uint8ClampedArrayRef::New(vm, arrayBuffer, 0, (int32_t)size);
|
||||||
typedArray->IsUint8ClampedArray();
|
typedArray->IsUint8ClampedArray();
|
||||||
@ -78,7 +78,7 @@ void IsInt16ArrayFuzztest(const uint8_t *data, size_t size)
|
|||||||
LOG_ECMA(ERROR) << "illegal input!";
|
LOG_ECMA(ERROR) << "illegal input!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||||
int32_t length = size / sizeof(int16_t);
|
int32_t length = size / sizeof(int16_t);
|
||||||
Local<JSValueRef> typedArray = Int16ArrayRef::New(vm, arrayBuffer, 0, length);
|
Local<JSValueRef> typedArray = Int16ArrayRef::New(vm, arrayBuffer, 0, length);
|
||||||
@ -95,7 +95,7 @@ void IsUint16ArrayFuzztest(const uint8_t *data, size_t size)
|
|||||||
LOG_ECMA(ERROR) << "illegal input!";
|
LOG_ECMA(ERROR) << "illegal input!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||||
int32_t length = size / sizeof(uint16_t);
|
int32_t length = size / sizeof(uint16_t);
|
||||||
Local<JSValueRef> typedArray = Uint16ArrayRef::New(vm, arrayBuffer, 0, length);
|
Local<JSValueRef> typedArray = Uint16ArrayRef::New(vm, arrayBuffer, 0, length);
|
||||||
|
@ -40,7 +40,7 @@ void JSValueRefIsPromiseValueFuzzTest(const uint8_t *data, size_t size)
|
|||||||
Local<PromiseCapabilityRef> capability = PromiseCapabilityRef::New(vm);
|
Local<PromiseCapabilityRef> capability = PromiseCapabilityRef::New(vm);
|
||||||
Local<PromiseRef> promise = capability->GetPromise(vm);
|
Local<PromiseRef> promise = capability->GetPromise(vm);
|
||||||
FunctionCallback nativeFunc = RejectCallback;
|
FunctionCallback nativeFunc = RejectCallback;
|
||||||
Deleter deleter = nullptr;
|
NativePointerCallback deleter = nullptr;
|
||||||
Local<FunctionRef> reject = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
Local<FunctionRef> reject = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
||||||
Local<PromiseRef> catchPromise = promise->Catch(vm, reject);
|
Local<PromiseRef> catchPromise = promise->Catch(vm, reject);
|
||||||
promise->IsPromise();
|
promise->IsPromise();
|
||||||
|
Loading…
Reference in New Issue
Block a user