mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Remove handle self
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB3F58 Signed-off-by: xwcai98 <caixinwei5@huawei.com> Change-Id: Id7f26e8a0275d54d6f1c499e66322b1882bbed83
This commit is contained in:
parent
e38204de36
commit
bb7b0fd181
@ -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);
|
||||
|
@ -959,22 +959,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);
|
||||
@ -990,33 +991,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);
|
||||
@ -1033,14 +1034,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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,10 +312,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,
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2970,17 +2970,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));
|
||||
@ -3010,14 +3011,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()) {
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -254,7 +254,7 @@ void ModuleManager::StoreModuleValueInternal(JSHandle<SourceTextModule> ¤t
|
||||
}
|
||||
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> ¤t
|
||||
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);
|
||||
}
|
||||
|
@ -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++) {
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
@ -1635,8 +1635,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);
|
||||
@ -2042,7 +2042,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);
|
||||
@ -2090,7 +2090,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();
|
||||
@ -2142,7 +2142,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);
|
||||
|
||||
@ -2186,7 +2186,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());
|
||||
@ -2459,7 +2459,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);
|
||||
@ -2491,7 +2491,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);
|
||||
@ -2526,7 +2526,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);
|
||||
@ -2547,7 +2547,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);
|
||||
@ -2568,7 +2568,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);
|
||||
@ -2589,7 +2589,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);
|
||||
@ -2610,7 +2610,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);
|
||||
@ -2631,7 +2631,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);
|
||||
@ -2663,7 +2663,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");
|
||||
@ -2685,7 +2685,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");
|
||||
@ -2831,7 +2831,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(
|
||||
@ -2852,7 +2852,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();
|
||||
@ -2880,7 +2880,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();
|
||||
@ -2906,7 +2906,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();
|
||||
@ -3138,7 +3138,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();
|
||||
@ -3335,7 +3335,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());
|
||||
}
|
||||
|
||||
@ -3865,7 +3865,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();
|
||||
@ -3885,7 +3885,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);
|
||||
@ -3915,7 +3915,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);
|
||||
|
@ -2950,7 +2950,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)
|
||||
@ -2982,7 +2982,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,
|
||||
@ -2994,7 +2994,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 ------------------------------------
|
||||
@ -3287,7 +3288,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));
|
||||
}
|
||||
@ -3300,8 +3302,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));
|
||||
}
|
||||
@ -3314,7 +3316,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));
|
||||
}
|
||||
@ -3331,7 +3333,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));
|
||||
}
|
||||
@ -3344,7 +3346,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));
|
||||
}
|
||||
@ -3383,7 +3385,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);
|
||||
}
|
||||
@ -3401,7 +3404,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);
|
||||
}
|
||||
@ -3419,7 +3422,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);
|
||||
}
|
||||
@ -3461,7 +3464,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) {
|
||||
@ -3752,9 +3755,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user