!10194 Remove handle self

Merge pull request !10194 from XinweiCai/remove_handle_self
This commit is contained in:
openharmony_ci 2024-11-12 11:59:42 +00:00 committed by Gitee
commit 01de85f868
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
16 changed files with 118 additions and 106 deletions

View File

@ -242,7 +242,7 @@ void JSArray::SetCapacity(JSThread *thread, const JSHandle<JSObject> &array,
if (newLen <= capacity) {
// judge if need to cut down the array size, else fill the unused tail with holes
CheckAndCopyArray(thread, JSHandle<JSArray>(array));
array->FillElementsWithHoles(thread, newLen, oldLen < capacity ? oldLen : capacity);
JSObject::FillElementsWithHoles(thread, array, newLen, oldLen < capacity ? oldLen : capacity);
}
if (JSObject::ShouldTransToDict(oldLen, newLen)) {
JSObject::ElementsToDictionary(thread, array);

View File

@ -960,22 +960,23 @@ void JSFunction::SetFunctionLength(const JSThread *thread, JSTaggedValue length)
SetPropertyInlinedProps(thread, LENGTH_INLINE_PROPERTY_INDEX, length);
}
void JSFunction::SetFunctionExtraInfo(JSThread *thread, void *nativeFunc, const NativePointerCallback &deleter,
void *data, size_t nativeBindingsize, Concurrent isConcurrent)
// static
void JSFunction::SetFunctionExtraInfo(JSThread *thread, const JSHandle<JSFunction> &func, void *nativeFunc,
const NativePointerCallback &deleter, void *data, size_t nativeBindingsize,
Concurrent isConcurrent)
{
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(*func, HASH_OFFSET);
EcmaVM *vm = thread->GetEcmaVM();
JSHandle<JSTaggedValue> value(thread, JSTaggedValue(hashField));
JSHandle<ECMAObject> obj(thread, this);
JSHandle<JSNativePointer> pointer = vm->GetFactory()->NewJSNativePointer(nativeFunc, deleter, data,
false, nativeBindingsize, isConcurrent);
if (!obj->HasHash()) {
Barriers::SetObject<true>(thread, *obj, HASH_OFFSET, pointer.GetTaggedValue().GetRawData());
if (!func->HasHash()) {
Barriers::SetObject<true>(thread, *func, HASH_OFFSET, pointer.GetTaggedValue().GetRawData());
return;
}
if (value->IsHeapObject()) {
if (value->IsJSNativePointer()) {
Barriers::SetObject<true>(thread, *obj, HASH_OFFSET, pointer.GetTaggedValue().GetRawData());
Barriers::SetObject<true>(thread, *func, HASH_OFFSET, pointer.GetTaggedValue().GetRawData());
return;
}
JSHandle<TaggedArray> array(value);
@ -991,33 +992,33 @@ void JSFunction::SetFunctionExtraInfo(JSThread *thread, void *nativeFunc, const
}
newArray->Set(thread, nativeFieldCount + HASH_INDEX, array->Get(nativeFieldCount + HASH_INDEX));
newArray->Set(thread, nativeFieldCount + FUNCTION_EXTRA_INDEX, pointer);
Barriers::SetObject<true>(thread, *obj, HASH_OFFSET, newArray.GetTaggedValue().GetRawData());
Barriers::SetObject<true>(thread, *func, HASH_OFFSET, newArray.GetTaggedValue().GetRawData());
}
} else {
JSHandle<TaggedArray> newArray = vm->GetFactory()->NewTaggedArray(RESOLVED_MAX_SIZE);
newArray->SetExtraLength(0);
newArray->Set(thread, HASH_INDEX, value);
newArray->Set(thread, FUNCTION_EXTRA_INDEX, pointer);
Barriers::SetObject<true>(thread, *obj, HASH_OFFSET, newArray.GetTaggedValue().GetRawData());
Barriers::SetObject<true>(thread, *func, HASH_OFFSET, newArray.GetTaggedValue().GetRawData());
}
}
void JSFunction::SetSFunctionExtraInfo(
JSThread *thread, void *nativeFunc, const NativePointerCallback &deleter, void *data, size_t nativeBindingsize)
// static
void JSFunction::SetSFunctionExtraInfo(JSThread *thread, const JSHandle<JSFunction> &func, void *nativeFunc,
const NativePointerCallback &deleter, void *data, size_t nativeBindingsize)
{
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(*func, HASH_OFFSET);
EcmaVM *vm = thread->GetEcmaVM();
JSHandle<JSTaggedValue> value(thread, JSTaggedValue(hashField));
JSHandle<ECMAObject> obj(thread, this);
JSHandle<JSNativePointer> pointer =
vm->GetFactory()->NewSJSNativePointer(nativeFunc, deleter, data, false, nativeBindingsize);
if (!obj->HasHash()) {
Barriers::SetObject<true>(thread, *obj, HASH_OFFSET, pointer.GetTaggedValue().GetRawData());
if (!func->HasHash()) {
Barriers::SetObject<true>(thread, *func, HASH_OFFSET, pointer.GetTaggedValue().GetRawData());
return;
}
if (value->IsHeapObject()) {
if (value->IsJSNativePointer()) {
Barriers::SetObject<true>(thread, *obj, HASH_OFFSET, pointer.GetTaggedValue().GetRawData());
Barriers::SetObject<true>(thread, *func, HASH_OFFSET, pointer.GetTaggedValue().GetRawData());
return;
}
JSHandle<TaggedArray> array(value);
@ -1034,14 +1035,14 @@ void JSFunction::SetSFunctionExtraInfo(
}
newArray->Set(thread, nativeFieldCount + HASH_INDEX, array->Get(nativeFieldCount + HASH_INDEX));
newArray->Set(thread, nativeFieldCount + FUNCTION_EXTRA_INDEX, pointer);
Barriers::SetObject<true>(thread, *obj, HASH_OFFSET, newArray.GetTaggedValue().GetRawData());
Barriers::SetObject<true>(thread, *func, HASH_OFFSET, newArray.GetTaggedValue().GetRawData());
}
} else {
JSHandle<TaggedArray> newArray = vm->GetFactory()->NewSTaggedArrayWithoutInit(RESOLVED_MAX_SIZE);
newArray->SetExtraLength(0);
newArray->Set(thread, HASH_INDEX, value);
newArray->Set(thread, FUNCTION_EXTRA_INDEX, pointer);
Barriers::SetObject<true>(thread, *obj, HASH_OFFSET, newArray.GetTaggedValue().GetRawData());
Barriers::SetObject<true>(thread, *func, HASH_OFFSET, newArray.GetTaggedValue().GetRawData());
}
}

View File

@ -326,10 +326,11 @@ public:
!ProfileTypeInfoCell::Cast(GetRawProfileTypeInfo())->GetValue().IsUndefined();
}
void SetFunctionExtraInfo(JSThread *thread, void *nativeFunc, const NativePointerCallback &deleter,
void *data, size_t nativeBindingsize = 0, Concurrent isConcurrent = Concurrent::NO);
void SetSFunctionExtraInfo(JSThread *thread, void *nativeFunc, const NativePointerCallback &deleter,
void *data, size_t nativeBindingsize = 0);
static void SetFunctionExtraInfo(JSThread *thread, const JSHandle<JSFunction> &func, void *nativeFunc,
const NativePointerCallback &deleter, void *data, size_t nativeBindingsize = 0,
Concurrent isConcurrent = Concurrent::NO);
static void SetSFunctionExtraInfo(JSThread *thread, const JSHandle<JSFunction> &func, void *nativeFunc,
const NativePointerCallback &deleter, void *data, size_t nativeBindingsize = 0);
static void SetProfileTypeInfo(const JSThread *thread, const JSHandle<JSFunction> &func,
const JSHandle<JSTaggedValue> &value, BarrierMode mode = WRITE_BARRIER);
static void UpdateProfileTypeInfoCell(JSThread *thread, JSHandle<FunctionTemplate> literalFunc,

View File

@ -45,16 +45,16 @@ inline bool JSObject::IsExtensible() const
return GetJSHClass()->IsExtensible();
}
inline void JSObject::FillElementsWithHoles(const JSThread *thread, uint32_t start, uint32_t end)
// static
inline void JSObject::FillElementsWithHoles(const JSThread *thread, const JSHandle<JSObject> &obj,
uint32_t start, uint32_t end)
{
if (start >= end) {
return;
}
JSHandle<JSTaggedValue> holeHandle(thread, JSTaggedValue::Hole());
JSHandle<JSObject> thisObj(thread, this);
for (uint32_t i = start; i < end; i++) {
ElementAccessor::Set(thread, thisObj, i, holeHandle, false);
ElementAccessor::Set(thread, obj, i, holeHandle, false);
}
}

View File

@ -2971,17 +2971,18 @@ void *ECMAObject::GetNativePointerField(int32_t index) const
return nullptr;
}
void ECMAObject::SetNativePointerField(const JSThread *thread, int32_t index, void *nativePointer,
const NativePointerCallback &callBack, void *data, size_t nativeBindingsize, Concurrent isConcurrent)
// static
void ECMAObject::SetNativePointerField(const JSThread *thread, const JSHandle<JSObject> &obj, int32_t index,
void *nativePointer, const NativePointerCallback &callBack, void *data,
size_t nativeBindingsize, Concurrent isConcurrent)
{
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(*obj, HASH_OFFSET);
JSTaggedValue value(hashField);
if (value.IsTaggedArray()) {
JSHandle<TaggedArray> array(thread, value);
if (static_cast<int32_t>(array->GetExtraLength()) > index) {
EcmaVM *vm = thread->GetEcmaVM();
JSHandle<JSTaggedValue> current = JSHandle<JSTaggedValue>(thread, array->Get(thread, index));
JSHandle<JSTaggedValue> obj(thread, this);
if (!current->IsHole() && nativePointer == nullptr) {
// Try to remove native pointer if exists.
vm->RemoveFromNativePointerList(*JSHandle<JSNativePointer>(current));
@ -3011,14 +3012,14 @@ int32_t ECMAObject::GetNativePointerFieldCount() const
return len;
}
void ECMAObject::SetNativePointerFieldCount(const JSThread *thread, int32_t count)
// static
void ECMAObject::SetNativePointerFieldCount(const JSThread *thread, const JSHandle<JSObject> &obj, int32_t count)
{
if (count == 0) {
return;
}
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(*obj, HASH_OFFSET);
JSHandle<JSTaggedValue> value(thread, JSTaggedValue(hashField));
JSHandle<ECMAObject> obj(thread, this);
JSHandle<JSTaggedValue> object(obj);
bool isShared = object->IsJSShared();
if (value->IsHeapObject()) {

View File

@ -385,11 +385,11 @@ public:
}
void* GetNativePointerField(int32_t index) const;
void SetNativePointerField(const JSThread *thread, int32_t index, void *nativePointer,
const NativePointerCallback &callBack, void *data, size_t nativeBindingsize = 0,
Concurrent isConcurrent = Concurrent::NO);
static void SetNativePointerField(const JSThread *thread, const JSHandle<JSObject> &obj, int32_t index,
void *nativePointer, const NativePointerCallback &callBack, void *data,
size_t nativeBindingsize = 0, Concurrent isConcurrent = Concurrent::NO);
int32_t GetNativePointerFieldCount() const;
void SetNativePointerFieldCount(const JSThread *thread, int32_t count);
static void SetNativePointerFieldCount(const JSThread *thread, const JSHandle<JSObject> &obj, int32_t count);
DECL_VISIT_OBJECT(HASH_OFFSET, SIZE);
@ -605,7 +605,8 @@ public:
const JSHandle<JSTaggedValue> &receiver,
const JSHandle<JSTaggedValue> &value, bool mayThrow = false);
void FillElementsWithHoles(const JSThread *thread, uint32_t start, uint32_t end);
static void FillElementsWithHoles(const JSThread *thread, const JSHandle<JSObject> &obj,
uint32_t start, uint32_t end);
JSHClass *GetJSHClass() const
{

View File

@ -254,7 +254,7 @@ void ModuleManager::StoreModuleValueInternal(JSHandle<SourceTextModule> &current
}
JSThread *thread = vm_->GetJSThread();
JSHandle<JSTaggedValue> valueHandle(thread, value);
currentModule->StoreModuleValue(thread, index, valueHandle);
SourceTextModule::StoreModuleValue(thread, currentModule, index, valueHandle);
}
JSTaggedValue ModuleManager::GetModuleValueInner(JSTaggedValue key)
@ -342,7 +342,7 @@ void ModuleManager::StoreModuleValueInternal(JSHandle<SourceTextModule> &current
JSThread *thread = vm_->GetJSThread();
JSHandle<JSTaggedValue> keyHandle(thread, key);
JSHandle<JSTaggedValue> valueHandle(thread, value);
currentModule->StoreModuleValue(thread, keyHandle, valueHandle);
SourceTextModule::StoreModuleValue(thread, currentModule, keyHandle, valueHandle);
}
JSHandle<SourceTextModule> ModuleManager::GetImportedModule(const CString &referencing)
{
@ -610,7 +610,7 @@ JSHandle<JSTaggedValue> ModuleManager::ExecuteNativeModuleMayThrowError(JSThread
JSHandle<JSTaggedValue>(thread, JSTaggedValue::Undefined()));
nativeModule->SetStatus(ModuleStatus::EVALUATED);
nativeModule->SetLoadingTypes(LoadingTypes::STABLE_MODULE);
nativeModule->StoreModuleValue(thread, 0, JSNApiHelper::ToJSHandle(exportObject));
SourceTextModule::StoreModuleValue(thread, nativeModule, 0, JSNApiHelper::ToJSHandle(exportObject));
AddResolveImportedModule(recordName, moduleRecord.GetTaggedValue());
return JSNApiHelper::ToJSHandle(exportObject);
}

View File

@ -177,7 +177,7 @@ JSHandle<TaggedArray> ModuleNamespace::OwnPropertyKeys(JSThread *thread, const J
JSHandle<ModuleNamespace> moduleNamespace = JSHandle<ModuleNamespace>::Cast(obj);
JSHandle<JSTaggedValue> exports(thread, moduleNamespace->GetExports());
JSHandle<TaggedArray> exportsArray = JSArray::ToTaggedArray(thread, exports);
if (!moduleNamespace->ValidateKeysAvailable(thread, exportsArray)) {
if (!ModuleNamespace::ValidateKeysAvailable(thread, moduleNamespace, exportsArray)) {
return exportsArray;
}
@ -196,7 +196,7 @@ JSHandle<TaggedArray> ModuleNamespace::OwnEnumPropertyKeys(JSThread *thread, con
JSHandle<ModuleNamespace> moduleNamespace = JSHandle<ModuleNamespace>::Cast(obj);
JSHandle<JSTaggedValue> exports(thread, moduleNamespace->GetExports());
JSHandle<TaggedArray> exportsArray = JSArray::ToTaggedArray(thread, exports);
if (!moduleNamespace->ValidateKeysAvailable(thread, exportsArray)) {
if (!ModuleNamespace::ValidateKeysAvailable(thread, moduleNamespace, exportsArray)) {
return exportsArray;
}
@ -351,9 +351,10 @@ bool ModuleNamespace::DeleteProperty(JSThread *thread, const JSHandle<JSTaggedVa
return true;
}
bool ModuleNamespace::ValidateKeysAvailable(JSThread *thread, const JSHandle<TaggedArray> &exports)
// static
bool ModuleNamespace::ValidateKeysAvailable(JSThread *thread, const JSHandle<ModuleNamespace> &moduleNamespace,
const JSHandle<TaggedArray> &exports)
{
JSHandle<ModuleNamespace> moduleNamespace(thread, this);
JSHandle<SourceTextModule> mm(thread, moduleNamespace->GetModule());
uint32_t exportsLength = exports->GetLength();
for (uint32_t idx = 0; idx < exportsLength; idx++) {

View File

@ -58,7 +58,8 @@ public:
static JSHandle<TaggedArray> OwnEnumPropertyKeys(JSThread *thread, const JSHandle<JSTaggedValue> &obj);
bool ValidateKeysAvailable(JSThread *thread, const JSHandle<TaggedArray> &exports);
static bool ValidateKeysAvailable(JSThread *thread, const JSHandle<ModuleNamespace> &moduleNamespace,
const JSHandle<TaggedArray> &exports);
static constexpr size_t MODULE_OFFSET = JSObject::SIZE;
ACCESSORS(Module, MODULE_OFFSET, EXPORTS_OFFSET)

View File

@ -389,12 +389,12 @@ bool SourceTextModule::LoadNativeModule(JSThread *thread, const JSHandle<SourceT
return false;
}
if (UNLIKELY(exportObject->IsNativeModuleFailureInfoObject(vm))) {
requiredModule->StoreModuleValue(thread, 0, JSNApiHelper::ToJSHandle(exportObject));
SourceTextModule::StoreModuleValue(thread, requiredModule, 0, JSNApiHelper::ToJSHandle(exportObject));
LOG_FULL(ERROR) << "loading fails, NativeModuleErrorObject is returned";
return false;
}
ASSERT(!thread->HasPendingException());
requiredModule->StoreModuleValue(thread, 0, JSNApiHelper::ToJSHandle(exportObject));
SourceTextModule::StoreModuleValue(thread, requiredModule, 0, JSNApiHelper::ToJSHandle(exportObject));
return true;
}
@ -1358,9 +1358,10 @@ JSTaggedValue SourceTextModule::FindByExport(const JSTaggedValue &exportEntriesT
return JSTaggedValue::Hole();
}
void SourceTextModule::StoreModuleValue(JSThread *thread, int32_t index, const JSHandle<JSTaggedValue> &value)
// static
void SourceTextModule::StoreModuleValue(JSThread *thread, const JSHandle<SourceTextModule> &module, int32_t index,
const JSHandle<JSTaggedValue> &value)
{
JSHandle<SourceTextModule> module(thread, this);
if (UNLIKELY(IsSharedModule(module)) && !value->IsSharedType()) {
CString msg = "Export non-shared object from shared-module, module name is :" +
module->GetEcmaModuleRecordNameString();
@ -1386,11 +1387,11 @@ void SourceTextModule::StoreModuleValue(JSThread *thread, int32_t index, const J
arr->Set(thread, index, value);
}
// discard instructions won't consider shared-module.
void SourceTextModule::StoreModuleValue(JSThread *thread, const JSHandle<JSTaggedValue> &key,
const JSHandle<JSTaggedValue> &value)
// static
// discard instructions won't consider shared-module.
void SourceTextModule::StoreModuleValue(JSThread *thread, const JSHandle<SourceTextModule> &module,
const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &value)
{
JSHandle<SourceTextModule> module(thread, this);
if (UNLIKELY(IsSharedModule(module)) && !value->IsSharedType()) {
CString msg = "Export non-shared object from shared-module, module name is :" +
module->GetEcmaModuleRecordNameString();

View File

@ -345,10 +345,12 @@ public:
ModuleTypes moduleType);
JSTaggedValue GetModuleValue(JSThread *thread, int32_t index, bool isThrow);
void StoreModuleValue(JSThread *thread, int32_t index, const JSHandle<JSTaggedValue> &value);
static void StoreModuleValue(JSThread *thread, const JSHandle<SourceTextModule> &module, int32_t index,
const JSHandle<JSTaggedValue> &value);
JSTaggedValue GetModuleValue(JSThread *thread, JSTaggedValue key, bool isThrow);
void StoreModuleValue(JSThread *thread, const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &value);
static void StoreModuleValue(JSThread *thread, const JSHandle<SourceTextModule> &module,
const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &value);
static JSTaggedValue GetValueFromExportObject(JSThread *thread, JSHandle<JSTaggedValue> &exportObject,
int32_t index);

View File

@ -122,7 +122,7 @@ JSHandle<JSTaggedValue> ModuleDataExtractor::ParseJsonModule(JSThread *thread, c
defaultName, LocalExportEntry::LOCAL_DEFAULT_INDEX, SharedTypes::UNSENDABLE_MODULE);
SourceTextModule::AddLocalExportEntry(thread, moduleRecord, localExportEntry, 0, 1); // 1 means len
JSTaggedValue jsonData = JsonParse(thread, jsPandaFile, recordName);
moduleRecord->StoreModuleValue(thread, 0, JSHandle<JSTaggedValue>(thread, jsonData)); // index = 0
SourceTextModule::StoreModuleValue(thread, moduleRecord, 0, JSHandle<JSTaggedValue>(thread, jsonData)); // index = 0
moduleRecord->SetEcmaModuleFilenameString(moduleFilename);
@ -149,7 +149,7 @@ JSHandle<JSTaggedValue> ModuleDataExtractor::ParseNativeModule(JSThread *thread,
moduleRecord->SetTypes(moduleType);
moduleRecord->SetIsNewBcVersion(true);
moduleRecord->SetStatus(ModuleStatus::INSTANTIATED);
moduleRecord->StoreModuleValue(thread, 0, thread->GlobalConstants()->GetHandledUndefined());
SourceTextModule::StoreModuleValue(thread, moduleRecord, 0, thread->GlobalConstants()->GetHandledUndefined());
return JSHandle<JSTaggedValue>::Cast(moduleRecord);
}

View File

@ -210,7 +210,7 @@ HWTEST_F_L0(EcmaModuleTest, StoreModuleValue)
JSHandle<JSTaggedValue> storeKey = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(localName));
JSHandle<JSTaggedValue> valueHandle = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(value));
module->StoreModuleValue(thread, storeKey, valueHandle);
SourceTextModule::StoreModuleValue(thread, module, storeKey, valueHandle);
JSHandle<JSTaggedValue> loadKey = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(localName));
JSTaggedValue loadValue = module->GetModuleValue(thread, loadKey.GetTaggedValue(), false);
@ -242,7 +242,7 @@ HWTEST_F_L0(EcmaModuleTest, GetModuleValue)
SourceTextModule::AddLocalExportEntry(thread, moduleExport, localExportEntry, 0, 1);
// store module value
JSHandle<JSTaggedValue> exportValueHandle = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(exportValue));
moduleExport->StoreModuleValue(thread, exportLocalNameHandle, exportValueHandle);
SourceTextModule::StoreModuleValue(thread, moduleExport, exportLocalNameHandle, exportValueHandle);
JSTaggedValue importDefaultValue =
moduleExport->GetModuleValue(thread, exportLocalNameHandle.GetTaggedValue(), false);
@ -288,11 +288,11 @@ HWTEST_F_L0(EcmaModuleTest, FindByExport)
JSHandle<JSTaggedValue> storeKey = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(localName1));
JSHandle<JSTaggedValue> valueHandle = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(value));
module->StoreModuleValue(thread, storeKey, valueHandle);
SourceTextModule::StoreModuleValue(thread, module, storeKey, valueHandle);
JSHandle<JSTaggedValue> storeKey2 = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(localName2));
JSHandle<JSTaggedValue> valueHandle2 = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(value2));
module->StoreModuleValue(thread, storeKey2, valueHandle2);
SourceTextModule::StoreModuleValue(thread, module, storeKey2, valueHandle2);
// FindByExport cannot find key from exportEntries, returns Hole()
JSHandle<JSTaggedValue> loadKey1 = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(localName3));
@ -1679,8 +1679,8 @@ HWTEST_F_L0(EcmaModuleTest, StoreModuleValue2)
JSHandle<JSTaggedValue> storeKey = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(localName));
JSHandle<JSTaggedValue> valueHandle = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(value));
JSHandle<JSTaggedValue> valueHandle1 = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(value2));
module->StoreModuleValue(thread, storeKey, valueHandle);
module->StoreModuleValue(thread, index, valueHandle1);
SourceTextModule::StoreModuleValue(thread, module, storeKey, valueHandle);
SourceTextModule::StoreModuleValue(thread, module, index, valueHandle1);
JSHandle<JSTaggedValue> loadKey = JSHandle<JSTaggedValue>::Cast(objFactory->NewFromUtf8(localName));
JSTaggedValue loadValue = module->GetModuleValue(thread, loadKey.GetTaggedValue(), false);
JSTaggedValue loadValue1 = module->GetModuleValue(thread, index, false);
@ -2097,7 +2097,7 @@ HWTEST_F_L0(EcmaModuleTest, ProcessModuleLoadInfoForESM)
JSHandle<TaggedArray> localExportEntries = objectFactory->NewTaggedArray(1);
localExportEntries->Set(thread, 0, localExportEntry);
module2->SetLocalExportEntries(thread, localExportEntries);
module2->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module2, 0, val);
module2->SetStatus(ModuleStatus::EVALUATED);
ModuleLogger *moduleLogger = new ModuleLogger(thread->GetEcmaVM());
thread->GetCurrentEcmaContext()->SetModuleLogger(moduleLogger);
@ -2145,7 +2145,7 @@ HWTEST_F_L0(EcmaModuleTest, ProcessModuleLoadInfoForCJS)
JSHandle<TaggedArray> localExportEntries = objectFactory->NewTaggedArray(1);
localExportEntries->Set(thread, 0, localExportEntry);
module2->SetLocalExportEntries(thread, localExportEntries);
module2->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module2, 0, val);
module2->SetTypes(ModuleTypes::CJS_MODULE);
module2->SetStatus(ModuleStatus::EVALUATED);
JSHandle<CjsModule> moduleCjs = objectFactory->NewCjsModule();
@ -2197,7 +2197,7 @@ HWTEST_F_L0(EcmaModuleTest, ProcessModuleLoadInfoForNativeModule)
JSHandle<TaggedArray> localExportEntries = objectFactory->NewTaggedArray(1);
localExportEntries->Set(thread, 0, localExportEntry);
module2->SetLocalExportEntries(thread, localExportEntries);
module2->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module2, 0, val);
module2->SetTypes(ModuleTypes::NATIVE_MODULE);
module2->SetStatus(ModuleStatus::EVALUATED);
@ -2241,7 +2241,7 @@ HWTEST_F_L0(EcmaModuleTest, ResolvedBindingForLog)
JSHandle<TaggedArray> localExportEntries = objectFactory->NewTaggedArray(1);
localExportEntries->Set(thread, 0, localExportEntry);
module2->SetLocalExportEntries(thread, localExportEntries);
module2->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module2, 0, val);
module2->SetStatus(ModuleStatus::EVALUATED);
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
moduleManager->AddResolveImportedModule(recordName2, module2.GetTaggedValue());
@ -2514,7 +2514,7 @@ HWTEST_F_L0(EcmaModuleTest, ResolveNativeStarExport)
JSHandle<TaggedArray> localExportEntries = objectFactory->NewTaggedArray(1);
localExportEntries->Set(thread, 0, localExportEntry);
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
JSHandle<JSTaggedValue> res1 = SourceTextModule::ResolveNativeStarExport(thread, module, val);
@ -2546,7 +2546,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModuleImpl)
JSHandle<TaggedArray> localExportEntries = objectFactory->NewTaggedArray(1);
localExportEntries->Set(thread, 0, localExportEntry);
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
ModuleLogger *moduleLogger = new ModuleLogger(vm);
thread->GetCurrentEcmaContext()->SetModuleLogger(moduleLogger);
@ -2581,7 +2581,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModuleMayThrowError1)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
Local<JSValueRef> requireNapi = StringRef::NewFromUtf8(vm, "requireNapi");
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);
@ -2602,7 +2602,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModuleMayThrowError2)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
Local<JSValueRef> requireNapi = StringRef::NewFromUtf8(vm, "requireNapi");
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);
@ -2623,7 +2623,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModuleMayThrowError3)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
Local<JSValueRef> requireNapi = StringRef::NewFromUtf8(vm, "requireNapi");
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);
@ -2644,7 +2644,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModuleMayThrowError4)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
Local<JSValueRef> requireNapi = StringRef::NewFromUtf8(vm, "requireNapi");
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);
@ -2665,7 +2665,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModule1)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
Local<JSValueRef> requireNapi = StringRef::NewFromUtf8(vm, "requireNapi");
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);
@ -2686,7 +2686,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModule2)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
Local<JSValueRef> requireNapi = StringRef::NewFromUtf8(vm, "requireNapi");
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);
@ -2718,7 +2718,7 @@ HWTEST_F_L0(EcmaModuleTest, EvaluateNativeModule2)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
module->SetStatus(ModuleStatus::INSTANTIATED);
Local<JSValueRef> requireNapi = StringRef::NewFromUtf8(vm, "requireNapi");
@ -2740,7 +2740,7 @@ HWTEST_F_L0(EcmaModuleTest, EvaluateNativeModule3)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
module->SetStatus(ModuleStatus::INSTANTIATED);
Local<JSValueRef> requireNapi = StringRef::NewFromUtf8(vm, "requireNapi");
@ -2886,7 +2886,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModule)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
JSHandle<JSTaggedValue> res = moduleManager->LoadNativeModule(
@ -2907,7 +2907,7 @@ HWTEST_F_L0(EcmaModuleTest, ExecuteNativeModuleMayThrowError)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString(recordName);
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
module->SetStatus(ModuleStatus::EVALUATED);
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
@ -2935,7 +2935,7 @@ HWTEST_F_L0(EcmaModuleTest, ExecuteNativeModule)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString(recordName);
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
@ -2961,7 +2961,7 @@ HWTEST_F_L0(EcmaModuleTest, ExecuteNativeModule2)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString(recordName);
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
@ -3193,7 +3193,7 @@ HWTEST_F_L0(EcmaModuleTest, GetLazyModuleValueFromRecordBinding)
JSHandle<TaggedArray> localExportEntries = objectFactory->NewTaggedArray(1);
localExportEntries->Set(thread, 0, localExportEntry);
module2->SetLocalExportEntries(thread, localExportEntries);
module2->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module2, 0, val);
module2->SetStatus(ModuleStatus::EVALUATED);
module2->SetTypes(ModuleTypes::NATIVE_MODULE);
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
@ -3390,7 +3390,7 @@ HWTEST_F_L0(EcmaModuleTest, StoreModuleValue4)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetLocalExportEntries(thread, localExportEntries);
module->SetSharedType(SharedTypes::SHARED_MODULE);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
EXPECT_TRUE(!thread->HasPendingException());
}
@ -3920,7 +3920,7 @@ HWTEST_F_L0(EcmaModuleTest, ResolveNativeStarExport2)
JSHandle<TaggedArray> localExportEntries = objectFactory->NewTaggedArray(1);
localExportEntries->Set(thread, 0, localExportEntry);
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
int arkProperties = thread->GetEcmaVM()->GetJSOptions().GetArkProperties();
@ -3940,7 +3940,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModuleImpl2)
JSHandle<TaggedArray> localExportEntries = objectFactory->NewTaggedArray(1);
localExportEntries->Set(thread, 0, localExportEntry);
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
ModuleLogger *moduleLogger = new ModuleLogger(vm);
thread->GetCurrentEcmaContext()->SetModuleLogger(moduleLogger);
@ -3970,7 +3970,7 @@ HWTEST_F_L0(EcmaModuleTest, LoadNativeModule3)
localExportEntries->Set(thread, 0, localExportEntry);
module->SetEcmaModuleRecordNameString("@app:bundleName/moduleName/lib*.so");
module->SetLocalExportEntries(thread, localExportEntries);
module->StoreModuleValue(thread, 0, val);
SourceTextModule::StoreModuleValue(thread, module, 0, val);
module->SetTypes(ModuleTypes::NATIVE_MODULE);
Local<JSValueRef> requireNapi = StringRef::NewFromUtf8(vm, "requireNapi");
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);

View File

@ -2948,7 +2948,7 @@ void ObjectRef::SetNativePointerFieldCount(const EcmaVM *vm, int32_t count)
// So we need do special value check before use it.
DCHECK_SPECIAL_VALUE(this);
JSHandle<JSObject> object(JSNApiHelper::ToJSHandle(this));
object->SetNativePointerFieldCount(thread, count);
ECMAObject::SetNativePointerFieldCount(thread, object, count);
}
int32_t ObjectRef::GetNativePointerFieldCount(const EcmaVM *vm)
@ -2980,7 +2980,7 @@ void ObjectRef::SetNativePointerField(const EcmaVM *vm, int32_t index, void *nat
// So we need do special value check before use it.
DCHECK_SPECIAL_VALUE(this);
JSHandle<JSObject> object(JSNApiHelper::ToJSHandle(this));
object->SetNativePointerField(thread, index, nativePointer, callBack, data, nativeBindingsize);
ECMAObject::SetNativePointerField(thread, object, index, nativePointer, callBack, data, nativeBindingsize);
}
void ObjectRef::SetConcurrentNativePointerField(const EcmaVM *vm, int32_t index, void *nativePointer,
@ -2992,7 +2992,8 @@ void ObjectRef::SetConcurrentNativePointerField(const EcmaVM *vm, int32_t index,
// So we need do special value check before use it.
DCHECK_SPECIAL_VALUE(this);
JSHandle<JSObject> object(JSNApiHelper::ToJSHandle(this));
object->SetNativePointerField(thread, index, nativePointer, callBack, data, nativeBindingsize, Concurrent::YES);
ECMAObject::SetNativePointerField(thread, object, index, nativePointer, callBack, data,
nativeBindingsize, Concurrent::YES);
}
// -------------------------------- NativePointerRef ------------------------------------
@ -3285,7 +3286,8 @@ Local<FunctionRef> FunctionRef::New(EcmaVM *vm, FunctionCallback nativeFunc,
ObjectFactory *factory = vm->GetFactory();
JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
JSHandle<JSFunction> current(factory->NewJSFunction(env, reinterpret_cast<void *>(Callback::RegisterCallback)));
current->SetFunctionExtraInfo(thread, reinterpret_cast<void *>(nativeFunc), deleter, data, nativeBindingsize);
JSFunction::SetFunctionExtraInfo(thread, current, reinterpret_cast<void *>(nativeFunc),
deleter, data, nativeBindingsize);
current->SetCallNapi(callNapi);
return JSNApiHelper::ToLocal<FunctionRef>(JSHandle<JSTaggedValue>(current));
}
@ -3298,8 +3300,8 @@ Local<FunctionRef> FunctionRef::NewConcurrent(EcmaVM *vm, FunctionCallback nativ
ObjectFactory *factory = vm->GetFactory();
JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
JSHandle<JSFunction> current(factory->NewJSFunction(env, reinterpret_cast<void *>(Callback::RegisterCallback)));
current->SetFunctionExtraInfo(thread, reinterpret_cast<void *>(nativeFunc), deleter,
data, nativeBindingsize, Concurrent::YES);
JSFunction::SetFunctionExtraInfo(thread, current, reinterpret_cast<void *>(nativeFunc), deleter,
data, nativeBindingsize, Concurrent::YES);
current->SetCallNapi(callNapi);
return JSNApiHelper::ToLocal<FunctionRef>(JSHandle<JSTaggedValue>(current));
}
@ -3312,7 +3314,7 @@ Local<FunctionRef> FunctionRef::New(EcmaVM *vm, InternalFunctionCallback nativeF
ObjectFactory *factory = vm->GetFactory();
JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
JSHandle<JSFunction> current(factory->NewJSFunction(env, reinterpret_cast<void *>(nativeFunc)));
current->SetFunctionExtraInfo(thread, nullptr, deleter, data, nativeBindingsize);
JSFunction::SetFunctionExtraInfo(thread, current, nullptr, deleter, data, nativeBindingsize);
current->SetCallNapi(callNapi);
return JSNApiHelper::ToLocal<FunctionRef>(JSHandle<JSTaggedValue>(current));
}
@ -3329,7 +3331,7 @@ Local<FunctionRef> FunctionRef::NewSendable(EcmaVM *vm,
ObjectFactory *factory = vm->GetFactory();
JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
JSHandle<JSFunction> current(factory->NewSFunction(env, reinterpret_cast<void *>(nativeFunc)));
current->SetSFunctionExtraInfo(thread, nullptr, deleter, data, nativeBindingsize);
JSFunction::SetSFunctionExtraInfo(thread, current, nullptr, deleter, data, nativeBindingsize);
current->SetCallNapi(callNapi);
return JSNApiHelper::ToLocal<FunctionRef>(JSHandle<JSTaggedValue>(current));
}
@ -3342,7 +3344,7 @@ Local<FunctionRef> FunctionRef::NewConcurrent(EcmaVM *vm, InternalFunctionCallba
ObjectFactory *factory = vm->GetFactory();
JSHandle<GlobalEnv> env = vm->GetGlobalEnv();
JSHandle<JSFunction> current(factory->NewJSFunction(env, reinterpret_cast<void *>(nativeFunc)));
current->SetFunctionExtraInfo(thread, nullptr, deleter, data, nativeBindingsize, Concurrent::YES);
JSFunction::SetFunctionExtraInfo(thread, current, nullptr, deleter, data, nativeBindingsize, Concurrent::YES);
current->SetCallNapi(callNapi);
return JSNApiHelper::ToLocal<FunctionRef>(JSHandle<JSTaggedValue>(current));
}
@ -3381,7 +3383,8 @@ Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, FunctionCallback na
factory->NewJSFunctionByHClass(reinterpret_cast<void *>(Callback::RegisterCallback),
hclass, ecmascript::FunctionKind::CLASS_CONSTRUCTOR);
InitClassFunction(vm, current, callNapi);
current->SetFunctionExtraInfo(thread, reinterpret_cast<void *>(nativeFunc), deleter, data, nativeBindingsize);
JSFunction::SetFunctionExtraInfo(thread, current, reinterpret_cast<void *>(nativeFunc),
deleter, data, nativeBindingsize);
Local<FunctionRef> result = JSNApiHelper::ToLocal<FunctionRef>(JSHandle<JSTaggedValue>(current));
return scope.Escape(result);
}
@ -3399,7 +3402,7 @@ Local<FunctionRef> FunctionRef::NewConcurrentClassFunction(EcmaVM *vm, InternalF
factory->NewJSFunctionByHClass(reinterpret_cast<void *>(nativeFunc),
hclass, ecmascript::FunctionKind::CLASS_CONSTRUCTOR);
InitClassFunction(vm, current, callNapi);
current->SetFunctionExtraInfo(thread, nullptr, deleter, data, nativeBindingsize, Concurrent::YES);
JSFunction::SetFunctionExtraInfo(thread, current, nullptr, deleter, data, nativeBindingsize, Concurrent::YES);
Local<FunctionRef> result = JSNApiHelper::ToLocal<FunctionRef>(JSHandle<JSTaggedValue>(current));
return scope.Escape(result);
}
@ -3417,7 +3420,7 @@ Local<FunctionRef> FunctionRef::NewClassFunction(EcmaVM *vm, InternalFunctionCal
factory->NewJSFunctionByHClass(reinterpret_cast<void *>(nativeFunc),
hclass, ecmascript::FunctionKind::CLASS_CONSTRUCTOR);
InitClassFunction(vm, current, callNapi);
current->SetFunctionExtraInfo(thread, nullptr, deleter, data, nativeBindingsize);
JSFunction::SetFunctionExtraInfo(thread, current, nullptr, deleter, data, nativeBindingsize);
Local<FunctionRef> result = JSNApiHelper::ToLocal<FunctionRef>(JSHandle<JSTaggedValue>(current));
return scope.Escape(result);
}
@ -3459,7 +3462,7 @@ Local<FunctionRef> FunctionRef::NewSendableClassFunction(const EcmaVM *vm,
constructor->SetProtoOrHClass(thread, prototype);
constructor->SetLexicalEnv(thread, constructor);
constructor->SetCallNapi(callNapi);
constructor->SetSFunctionExtraInfo(thread, nullptr, deleter, data, nativeBindingSize);
JSFunction::SetSFunctionExtraInfo(thread, constructor, nullptr, deleter, data, nativeBindingSize);
JSHClass *parentIHClass{nullptr};
if (hasParent) {
@ -3750,9 +3753,9 @@ void FunctionRef::SetData(const EcmaVM *vm, void *data, NativePointerCallback de
JSHandle<JSTaggedValue> funcValue = JSNApiHelper::ToJSHandle(this);
JSHandle<JSFunction> function(funcValue);
if (function->IsJSShared()) {
function->SetSFunctionExtraInfo(thread, nullptr, deleter, data, 0);
JSFunction::SetSFunctionExtraInfo(thread, function, nullptr, deleter, data, 0);
} else {
function->SetFunctionExtraInfo(thread, nullptr, deleter, data, 0);
JSFunction::SetFunctionExtraInfo(thread, function, nullptr, deleter, data, 0);
}
}

View File

@ -222,7 +222,7 @@ void JSSharedArray::SetCapacity(JSThread *thread, const JSHandle<JSObject> &arra
if (newLen <= capacity) {
// judge if need to cut down the array size, else fill the unused tail with holes
CheckAndCopyArray(thread, JSHandle<JSSharedArray>(array));
array->FillElementsWithHoles(thread, newLen, oldLen < capacity ? oldLen : capacity);
JSObject::FillElementsWithHoles(thread, array, newLen, oldLen < capacity ? oldLen : capacity);
}
if (newLen > capacity) {
JSObject::GrowElementsCapacity(thread, array, newLen, isNew);

View File

@ -1255,9 +1255,9 @@ HWTEST_F_L0(JSObjectTest, NativePointerField)
ECMAObject::SetHash(thread, 87, JSHandle<ECMAObject>::Cast(obj));
EXPECT_TRUE(obj->GetHash() == 87);
obj->SetNativePointerFieldCount(thread, 1);
ECMAObject::SetNativePointerFieldCount(thread, obj, 1);
char array[] = "Hello World!";
obj->SetNativePointerField(thread, 0, array, nullptr, nullptr);
ECMAObject::SetNativePointerField(thread, obj, 0, array, nullptr, nullptr);
int32_t count = obj->GetNativePointerFieldCount();
EXPECT_TRUE(count == 1);
void *pointer = obj->GetNativePointerField(0);