mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-02-17 02:10:00 +00:00
Forbidden Calling GetJSThread by Region
Forbidden calling getJSThread by region Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8VGW7?from=project-issue Signed-off-by: lukai <lukai25@huawei.com> Change-Id: Ieb42714f4ed7c44194134f4f0b4845217ef44d5e
This commit is contained in:
parent
78b1f5847e
commit
783fa0a6d2
@ -135,7 +135,7 @@ JSTaggedValue BuiltinsMap::Has(EcmaRuntimeCallInfo *argv)
|
||||
}
|
||||
JSMap *jsMap = JSMap::Cast(self.GetTaggedValue().GetTaggedObject());
|
||||
JSHandle<JSTaggedValue> key = GetCallArg(argv, 0);
|
||||
bool flag = jsMap->Has(key.GetTaggedValue());
|
||||
bool flag = jsMap->Has(thread, key.GetTaggedValue());
|
||||
return GetTaggedBoolean(flag);
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ JSTaggedValue BuiltinsMap::Get(EcmaRuntimeCallInfo *argv)
|
||||
}
|
||||
JSMap *jsMap = JSMap::Cast(self.GetTaggedValue().GetTaggedObject());
|
||||
JSHandle<JSTaggedValue> key = GetCallArg(argv, 0);
|
||||
JSTaggedValue value = jsMap->Get(key.GetTaggedValue());
|
||||
JSTaggedValue value = jsMap->Get(thread, key.GetTaggedValue());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ JSTaggedValue BuiltinsSet::Has(EcmaRuntimeCallInfo *argv)
|
||||
}
|
||||
JSSet* jsSet = JSSet::Cast(self.GetTaggedValue().GetTaggedObject());
|
||||
JSHandle<JSTaggedValue> value = GetCallArg(argv, 0);
|
||||
bool flag = jsSet->Has(value.GetTaggedValue());
|
||||
bool flag = jsSet->Has(thread, value.GetTaggedValue());
|
||||
return GetTaggedBoolean(flag);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ JSTaggedValue BuiltinsWeakMap::Has(EcmaRuntimeCallInfo *argv)
|
||||
if (!JSTaggedValue::CanBeHeldWeakly(thread, key)) {
|
||||
return GetTaggedBoolean(false);
|
||||
}
|
||||
return GetTaggedBoolean(jsWeakMap->Has(key.GetTaggedValue()));
|
||||
return GetTaggedBoolean(jsWeakMap->Has(thread, key.GetTaggedValue()));
|
||||
}
|
||||
|
||||
JSTaggedValue BuiltinsWeakMap::Get(EcmaRuntimeCallInfo *argv)
|
||||
@ -133,7 +133,7 @@ JSTaggedValue BuiltinsWeakMap::Get(EcmaRuntimeCallInfo *argv)
|
||||
if (!JSTaggedValue::CanBeHeldWeakly(thread, key)) {
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
return jsWeakMap->Get(key.GetTaggedValue());
|
||||
return jsWeakMap->Get(thread, key.GetTaggedValue());
|
||||
}
|
||||
|
||||
JSTaggedValue BuiltinsWeakMap::Set(EcmaRuntimeCallInfo *argv)
|
||||
|
@ -166,6 +166,6 @@ JSTaggedValue BuiltinsWeakSet::Has(EcmaRuntimeCallInfo *argv)
|
||||
if (!JSTaggedValue::CanBeHeldWeakly(thread, value)) {
|
||||
GetTaggedBoolean(false);
|
||||
}
|
||||
return GetTaggedBoolean(jsWeakSet->Has(value.GetTaggedValue()));
|
||||
return GetTaggedBoolean(jsWeakSet->Has(thread, value.GetTaggedValue()));
|
||||
}
|
||||
} // namespace panda::ecmascript::builtins
|
||||
|
@ -208,7 +208,7 @@ JSTaggedValue ContainersLightWeightSet::Has(EcmaRuntimeCallInfo *argv)
|
||||
}
|
||||
JSHandle<JSTaggedValue> value(GetCallArg(argv, 0));
|
||||
JSAPILightWeightSet *set = JSAPILightWeightSet::Cast(self->GetTaggedObject());
|
||||
return JSTaggedValue(set->Has(value));
|
||||
return JSTaggedValue(set->Has(thread, value));
|
||||
}
|
||||
|
||||
JSTaggedValue ContainersLightWeightSet::HasHash(EcmaRuntimeCallInfo *argv)
|
||||
@ -396,7 +396,7 @@ JSTaggedValue ContainersLightWeightSet::GetIndexOf(EcmaRuntimeCallInfo *argv)
|
||||
}
|
||||
JSHandle<JSTaggedValue> value(GetCallArg(argv, 0));
|
||||
JSAPILightWeightSet *set = JSAPILightWeightSet::Cast(self->GetTaggedObject());
|
||||
int32_t result = set->GetIndexOf(value);
|
||||
int32_t result = set->GetIndexOf(thread, value);
|
||||
return JSTaggedValue(result);
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,7 @@ int32_t DebuggerApi::GetObjectHash(const EcmaVM *ecmaVM, const JSHandle<JSTagged
|
||||
int32_t hash = base::RandomGenerator::GenerateIdentityHash();
|
||||
auto ecmaObj = ECMAObject::Cast(tagged->GetTaggedObject());
|
||||
JSHandle<ECMAObject> ecmaObjHandle(ecmaVM->GetJSThread(), ecmaObj);
|
||||
ECMAObject::SetHash(hash, ecmaObjHandle);
|
||||
ECMAObject::SetHash(ecmaVM->GetJSThread(), hash, ecmaObjHandle);
|
||||
return hash;
|
||||
} else {
|
||||
return ECMAObject::Cast(tagged->GetTaggedObject())->GetHash();
|
||||
|
@ -96,26 +96,26 @@
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define ACCESSORS_SYNCHRONIZED(name, offset, endOffset) \
|
||||
static constexpr size_t endOffset = (offset) + JSTaggedValue::TaggedTypeSize(); \
|
||||
JSTaggedValue Get##name() const \
|
||||
{ \
|
||||
/* Note: We can't statically decide the element type is a primitive or heap object, especially for */ \
|
||||
/* dynamically-typed languages like JavaScript. So we simply skip the read-barrier. */ \
|
||||
/* Synchronized means it will restrain the store and load in atomic. */ \
|
||||
return JSTaggedValue(reinterpret_cast<volatile std::atomic<JSTaggedType> *>(ToUintPtr(this) + offset) \
|
||||
->load(std::memory_order_acquire)); \
|
||||
} \
|
||||
template<typename T> \
|
||||
void Set##name([[maybe_unused]] const JSThread *thread, JSHandle<T> value) \
|
||||
{ \
|
||||
bool isPrimitive = !value.GetTaggedValue().IsHeapObject(); \
|
||||
Barriers::SynchronizedSetObject(this, offset, value.GetTaggedValue().GetRawData(), isPrimitive); \
|
||||
} \
|
||||
void Set##name([[maybe_unused]] const JSThread *thread, JSTaggedValue value) \
|
||||
{ \
|
||||
bool isPrimitive = !value.IsHeapObject(); \
|
||||
Barriers::SynchronizedSetObject(this, offset, value.GetRawData(), isPrimitive); \
|
||||
#define ACCESSORS_SYNCHRONIZED(name, offset, endOffset) \
|
||||
static constexpr size_t endOffset = (offset) + JSTaggedValue::TaggedTypeSize(); \
|
||||
JSTaggedValue Get##name() const \
|
||||
{ \
|
||||
/* Note: We can't statically decide the element type is a primitive or heap object, especially for */ \
|
||||
/* dynamically-typed languages like JavaScript. So we simply skip the read-barrier. */ \
|
||||
/* Synchronized means it will restrain the store and load in atomic. */ \
|
||||
return JSTaggedValue(reinterpret_cast<volatile std::atomic<JSTaggedType> *>(ToUintPtr(this) + offset) \
|
||||
->load(std::memory_order_acquire)); \
|
||||
} \
|
||||
template<typename T> \
|
||||
void Set##name(const JSThread *thread, JSHandle<T> value) \
|
||||
{ \
|
||||
bool isPrimitive = !value.GetTaggedValue().IsHeapObject(); \
|
||||
Barriers::SynchronizedSetObject(thread, this, offset, value.GetTaggedValue().GetRawData(), isPrimitive); \
|
||||
} \
|
||||
void Set##name(const JSThread *thread, JSTaggedValue value) \
|
||||
{ \
|
||||
bool isPrimitive = !value.IsHeapObject(); \
|
||||
Barriers::SynchronizedSetObject(thread, this, offset, value.GetRawData(), isPrimitive); \
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
|
@ -136,7 +136,8 @@ inline EcmaString *EcmaString::CreateLineStringNoGC(const EcmaVM *vm, size_t len
|
||||
size_t size = compressed ? LineEcmaString::ComputeSizeUtf8(length) : LineEcmaString::ComputeSizeUtf16(length);
|
||||
size = AlignUp(size, static_cast<size_t>(MemAlignment::MEM_ALIGN_OBJECT));
|
||||
auto object = reinterpret_cast<TaggedObject *>(vm->GetHeap()->GetOldSpace()->Allocate(size, false));
|
||||
object->SetClass(JSHClass::Cast(vm->GetJSThread()->GlobalConstants()->GetLineStringClass().GetTaggedObject()));
|
||||
auto thread = vm->GetJSThread();
|
||||
object->SetClass(thread, JSHClass::Cast(thread->GlobalConstants()->GetLineStringClass().GetTaggedObject()));
|
||||
auto string = EcmaString::Cast(object);
|
||||
string->SetLength(length, compressed);
|
||||
string->SetRawHashcode(0);
|
||||
|
@ -42,6 +42,7 @@ void GlobalEnv::Init(JSThread *thread)
|
||||
SetTemplateMap(thread, TemplateMap::Create(thread));
|
||||
SetObjectLiteralHClassCache(thread, JSTaggedValue::Hole());
|
||||
SetJsonObjectHclassCache(thread, JSTaggedValue::Hole());
|
||||
SetJSThread(thread);
|
||||
}
|
||||
JSHandle<JSTaggedValue> GlobalEnv::GetSymbol(JSThread *thread, const JSHandle<JSTaggedValue> &string)
|
||||
{
|
||||
|
@ -36,6 +36,8 @@ public:
|
||||
static constexpr uint8_t FIRST_DETECTOR_SYMBOL_INDEX = static_cast<uint8_t>(Field::REPLACE_SYMBOL_INDEX);
|
||||
static constexpr uint8_t LAST_DETECTOR_SYMBOL_INDEX = static_cast<uint8_t>(Field::ITERATOR_SYMBOL_INDEX);
|
||||
static constexpr uint8_t FINAL_INDEX = static_cast<uint8_t>(GlobalEnvField::FINAL_INDEX);
|
||||
static constexpr uint8_t RESERVED_LENGTH = 1; // divide the gc area
|
||||
static constexpr uint8_t JSTHREAD_INDEX = FINAL_INDEX; // not need gc
|
||||
#undef GLOBAL_ENV_SLOT
|
||||
|
||||
JSTaggedValue GetGlobalObject() const
|
||||
@ -80,6 +82,18 @@ public:
|
||||
return reinterpret_cast<GlobalEnv *>(object);
|
||||
}
|
||||
|
||||
JSThread* GetJSThread() const
|
||||
{
|
||||
uintptr_t address = ComputeObjectAddress(JSTHREAD_INDEX);
|
||||
return *reinterpret_cast<JSThread**>(address);
|
||||
}
|
||||
|
||||
void SetJSThread(JSThread *thread)
|
||||
{
|
||||
uintptr_t address = ComputeObjectAddress(JSTHREAD_INDEX);
|
||||
*reinterpret_cast<JSThread**>(address) = thread;
|
||||
}
|
||||
|
||||
JSHandle<JSTaggedValue> GetSymbol(JSThread *thread, const JSHandle<JSTaggedValue> &string);
|
||||
JSHandle<JSTaggedValue> GetStringFunctionByName(JSThread *thread, const char *name);
|
||||
JSHandle<JSTaggedValue> GetStringPrototypeFunctionByName(JSThread *thread, const char *name);
|
||||
@ -128,27 +142,28 @@ public:
|
||||
{ \
|
||||
uint32_t offset = HEADER_SIZE + index * JSTaggedValue::TaggedTypeSize(); \
|
||||
if (mode == WRITE_BARRIER && value.GetTaggedValue().IsHeapObject()) { \
|
||||
Barriers::SetObject<true>(thread, this, offset, value.GetTaggedValue().GetRawData()); \
|
||||
Barriers::SetObject<true>(thread, this, offset, value.GetTaggedValue().GetRawData()); \
|
||||
} else { \
|
||||
Barriers::SetPrimitive<JSTaggedType>(this, offset, value.GetTaggedValue().GetRawData()); \
|
||||
Barriers::SetPrimitive<JSTaggedType>(this, offset, value.GetTaggedValue().GetRawData()); \
|
||||
} \
|
||||
} \
|
||||
inline void Set##name(const JSThread *thread, type value, BarrierMode mode = WRITE_BARRIER) \
|
||||
{ \
|
||||
uint32_t offset = HEADER_SIZE + index * JSTaggedValue::TaggedTypeSize(); \
|
||||
if (mode == WRITE_BARRIER && value.IsHeapObject()) { \
|
||||
Barriers::SetObject<true>(thread, this, offset, value.GetRawData()); \
|
||||
Barriers::SetObject<true>(thread, this, offset, value.GetRawData()); \
|
||||
} else { \
|
||||
Barriers::SetPrimitive<JSTaggedType>(this, offset, value.GetRawData()); \
|
||||
Barriers::SetPrimitive<JSTaggedType>(this, offset, value.GetRawData()); \
|
||||
} \
|
||||
}
|
||||
GLOBAL_ENV_FIELDS(GLOBAL_ENV_FIELD_ACCESSORS)
|
||||
#undef GLOBAL_ENV_FIELD_ACCESSORS
|
||||
|
||||
static constexpr size_t HEADER_SIZE = TaggedObjectSize();
|
||||
static constexpr size_t SIZE = HEADER_SIZE + FINAL_INDEX * JSTaggedValue::TaggedTypeSize();
|
||||
static constexpr size_t DATA_SIZE = HEADER_SIZE + FINAL_INDEX * JSTaggedValue::TaggedTypeSize();
|
||||
static constexpr size_t SIZE = DATA_SIZE + RESERVED_LENGTH * JSTaggedValue::TaggedTypeSize();
|
||||
|
||||
DECL_VISIT_OBJECT(HEADER_SIZE, SIZE);
|
||||
DECL_VISIT_OBJECT(HEADER_SIZE, DATA_SIZE);
|
||||
|
||||
DECL_DUMP()
|
||||
};
|
||||
|
@ -301,7 +301,7 @@ void ICRuntimeStub::StoreWithTransition(JSThread *thread, JSObject *receiver, JS
|
||||
handlerInfo = static_cast<uint32_t>(transitionHandler->GetHandlerInfo().GetInt());
|
||||
}
|
||||
|
||||
receiver->SynchronizedSetClass(newHClass);
|
||||
receiver->SynchronizedSetClass(thread, newHClass);
|
||||
JSHandle<JSHClass> newHClassHandle(thread, newHClass);
|
||||
JSHandle<JSObject> objHandle(thread, receiver);
|
||||
JSHClass::TryRestoreElementsKind(thread, newHClassHandle, objHandle);
|
||||
|
@ -33,7 +33,7 @@ JSTaggedValue JSAPIHashMap::IsEmpty()
|
||||
JSTaggedValue JSAPIHashMap::HasKey(JSThread *thread, JSTaggedValue key)
|
||||
{
|
||||
TaggedHashArray *hashArray = TaggedHashArray::Cast(GetTable().GetTaggedObject());
|
||||
int hash = TaggedNode::Hash(key);
|
||||
int hash = TaggedNode::Hash(thread, key);
|
||||
return JSTaggedValue(!(hashArray->GetNode(thread, hash, key).IsHole()));
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ bool JSAPIHashMap::HasValueRBTreeNode(JSTaggedValue node, JSTaggedValue value)
|
||||
JSTaggedValue JSAPIHashMap::Replace(JSThread *thread, JSTaggedValue key, JSTaggedValue newValue)
|
||||
{
|
||||
TaggedHashArray *hashArray = TaggedHashArray::Cast(GetTable().GetTaggedObject());
|
||||
int hash = TaggedNode::Hash(key);
|
||||
int hash = TaggedNode::Hash(thread, key);
|
||||
JSTaggedValue nodeVa = hashArray->GetNode(thread, hash, key);
|
||||
if (nodeVa.IsHole()) {
|
||||
return JSTaggedValue::False();
|
||||
@ -120,7 +120,7 @@ void JSAPIHashMap::Set(JSThread *thread, JSHandle<JSAPIHashMap> hashMap,
|
||||
THROW_NEW_ERROR_AND_RETURN(thread, error);
|
||||
}
|
||||
JSHandle<TaggedHashArray> hashArray(thread, hashMap->GetTable());
|
||||
int hash = TaggedNode::Hash(key.GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, key.GetTaggedValue());
|
||||
JSTaggedValue setValue = TaggedHashArray::SetVal(thread, hashArray, hash, key, value);
|
||||
uint32_t nodeNum = hashMap->GetSize();
|
||||
if (!setValue.IsUndefined()) {
|
||||
@ -136,7 +136,7 @@ void JSAPIHashMap::Set(JSThread *thread, JSHandle<JSAPIHashMap> hashMap,
|
||||
JSTaggedValue JSAPIHashMap::Get(JSThread *thread, JSTaggedValue key)
|
||||
{
|
||||
TaggedHashArray *hashArray = TaggedHashArray::Cast(GetTable().GetTaggedObject());
|
||||
int hash = TaggedNode::Hash(key);
|
||||
int hash = TaggedNode::Hash(thread, key);
|
||||
JSTaggedValue node = hashArray->GetNode(thread, hash, key);
|
||||
if (node.IsHole()) {
|
||||
return JSTaggedValue::Undefined();
|
||||
@ -219,7 +219,7 @@ JSTaggedValue JSAPIHashMap::Remove(JSThread *thread, JSHandle<JSAPIHashMap> hash
|
||||
if (nodeNum == 0) {
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
int hash = TaggedNode::Hash(key);
|
||||
int hash = TaggedNode::Hash(thread, key);
|
||||
JSHandle<JSTaggedValue> removeValue(thread, hashArray->RemoveNode(thread, hash, key));
|
||||
if (removeValue->IsHole()) {
|
||||
return JSTaggedValue::Undefined();
|
||||
|
@ -39,7 +39,7 @@ JSTaggedValue JSAPIHashSet::Has(JSThread *thread, JSTaggedValue value)
|
||||
THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception());
|
||||
}
|
||||
TaggedHashArray *hashArray = TaggedHashArray::Cast(GetTable().GetTaggedObject());
|
||||
int hash = TaggedNode::Hash(value);
|
||||
int hash = TaggedNode::Hash(thread, value);
|
||||
return JSTaggedValue(!(hashArray->GetNode(thread, hash, value).IsHole()));
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ void JSAPIHashSet::Add(JSThread *thread, JSHandle<JSAPIHashSet> hashSet, JSHandl
|
||||
THROW_NEW_ERROR_AND_RETURN(thread, error);
|
||||
}
|
||||
JSHandle<TaggedHashArray> hashArray(thread, hashSet->GetTable());
|
||||
int hash = TaggedNode::Hash(value.GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, value.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> nullHandle(thread, JSTaggedValue::Null());
|
||||
JSTaggedValue setValue = TaggedHashArray::SetVal(thread, hashArray, hash, value, nullHandle);
|
||||
uint32_t nodeNum = hashSet->GetSize();
|
||||
@ -93,7 +93,7 @@ JSTaggedValue JSAPIHashSet::Remove(JSThread *thread, JSHandle<JSAPIHashSet> hash
|
||||
if (nodeNum == 0) {
|
||||
return JSTaggedValue::False();
|
||||
}
|
||||
int hash = TaggedNode::Hash(key);
|
||||
int hash = TaggedNode::Hash(thread, key);
|
||||
JSTaggedValue removeValue = hashArray->RemoveNode(thread, hash, key);
|
||||
if (removeValue.IsHole()) {
|
||||
return JSTaggedValue::False();
|
||||
|
@ -120,7 +120,7 @@ JSTaggedValue JSAPILightWeightMap::HasAll(JSThread *thread, const JSHandle<JSAPI
|
||||
|
||||
for (uint32_t num = 0; num < length; num++) {
|
||||
dealKey = newKeyArray->Get(num);
|
||||
hash = Hash(dealKey);
|
||||
hash = Hash(thread, dealKey);
|
||||
index = BinarySearchHashes(oldHashArray, hash, static_cast<int32_t>(len));
|
||||
if (index < 0 || index >= static_cast<int32_t>(len)) {
|
||||
return JSTaggedValue::False();
|
||||
@ -166,7 +166,7 @@ int32_t JSAPILightWeightMap::GetIndexOfKey(JSThread *thread, const JSHandle<JSAP
|
||||
KeyState JSAPILightWeightMap::GetStateOfKey(JSThread *thread, const JSHandle<JSAPILightWeightMap> &lightWeightMap,
|
||||
const JSHandle<JSTaggedValue> &key)
|
||||
{
|
||||
int32_t hash = Hash(key.GetTaggedValue());
|
||||
int32_t hash = Hash(thread, key.GetTaggedValue());
|
||||
int32_t length = static_cast<int32_t>(lightWeightMap->GetSize());
|
||||
JSHandle<TaggedArray> hashArray = GetArrayByKind(thread, lightWeightMap, AccossorsKind::HASH);
|
||||
int32_t index = BinarySearchHashes(hashArray, hash, length);
|
||||
@ -450,7 +450,7 @@ JSHandle<TaggedArray> JSAPILightWeightMap::GetArrayByKind(const JSThread *thread
|
||||
return array;
|
||||
}
|
||||
|
||||
int32_t JSAPILightWeightMap::Hash(JSTaggedValue key)
|
||||
int32_t JSAPILightWeightMap::Hash(const JSThread *thread, JSTaggedValue key)
|
||||
{
|
||||
if (key.IsDouble() && key.GetDouble() == 0.0) {
|
||||
key = JSTaggedValue(0);
|
||||
@ -467,9 +467,8 @@ int32_t JSAPILightWeightMap::Hash(JSTaggedValue key)
|
||||
uint32_t hash = ECMAObject::Cast(key.GetTaggedObject())->GetHash();
|
||||
if (hash == 0) {
|
||||
hash = base::RandomGenerator::GenerateIdentityHash();
|
||||
JSThread *thread = ECMAObject::Cast(key.GetTaggedObject())->GetJSThread();
|
||||
JSHandle<ECMAObject> ecmaObj(thread, key);
|
||||
ECMAObject::SetHash(hash, ecmaObj);
|
||||
ECMAObject::SetHash(thread, hash, ecmaObj);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ private:
|
||||
AccossorsKind kind);
|
||||
static void SetValue(const JSThread *thread, const JSHandle<JSAPILightWeightMap> &lightWeightMap,
|
||||
int32_t index, const JSHandle<JSTaggedValue> &value, AccossorsKind kind);
|
||||
static int32_t Hash(JSTaggedValue key);
|
||||
static int32_t Hash(const JSThread *thread, JSTaggedValue key);
|
||||
static int32_t BinarySearchHashes(JSHandle<TaggedArray> &array, int32_t hash, int32_t size);
|
||||
static JSHandle<TaggedArray> GetArrayByKind(const JSThread *thread,
|
||||
const JSHandle<JSAPILightWeightMap> &lightWeightMap,
|
||||
|
@ -29,11 +29,11 @@ using ErrorFlag = containers::ErrorFlag;
|
||||
bool JSAPILightWeightSet::Add(JSThread *thread, const JSHandle<JSAPILightWeightSet> &obj,
|
||||
const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
uint32_t hashCode = obj->Hash(value.GetTaggedValue());
|
||||
uint32_t hashCode = obj->Hash(thread, value.GetTaggedValue());
|
||||
JSHandle<TaggedArray> hashArray(thread, obj->GetHashes());
|
||||
JSHandle<TaggedArray> valueArray(thread, obj->GetValues());
|
||||
int32_t size = static_cast<int32_t>(obj->GetLength());
|
||||
int32_t index = obj->GetHashIndex(value, size);
|
||||
int32_t index = obj->GetHashIndex(thread, value, size);
|
||||
if (index >= 0) {
|
||||
return false;
|
||||
}
|
||||
@ -75,9 +75,9 @@ JSHandle<TaggedArray> JSAPILightWeightSet::CreateSlot(const JSThread *thread, co
|
||||
return taggedArray;
|
||||
}
|
||||
|
||||
int32_t JSAPILightWeightSet::GetHashIndex(const JSHandle<JSTaggedValue> &value, int32_t size)
|
||||
int32_t JSAPILightWeightSet::GetHashIndex(const JSThread *thread, const JSHandle<JSTaggedValue> &value, int32_t size)
|
||||
{
|
||||
uint32_t hashCode = Hash(value.GetTaggedValue());
|
||||
uint32_t hashCode = Hash(thread, value.GetTaggedValue());
|
||||
int32_t index = BinarySearchHashes(hashCode, size);
|
||||
if (index < 0) {
|
||||
return index;
|
||||
@ -223,10 +223,10 @@ bool JSAPILightWeightSet::HasAll(const JSHandle<JSTaggedValue> &value)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool JSAPILightWeightSet::Has(const JSHandle<JSTaggedValue> &value)
|
||||
bool JSAPILightWeightSet::Has(const JSThread *thread, const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
uint32_t size = GetLength();
|
||||
int32_t index = GetHashIndex(value, size);
|
||||
int32_t index = GetHashIndex(thread, value, size);
|
||||
if (index < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -337,10 +337,10 @@ JSTaggedValue JSAPILightWeightSet::ForEach(JSThread *thread, const JSHandle<JSTa
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
|
||||
int32_t JSAPILightWeightSet::GetIndexOf(JSHandle<JSTaggedValue> &value)
|
||||
int32_t JSAPILightWeightSet::GetIndexOf(const JSThread *thread, JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
uint32_t size = GetLength();
|
||||
int32_t index = GetHashIndex(value, size);
|
||||
int32_t index = GetHashIndex(thread, value, size);
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ JSTaggedValue JSAPILightWeightSet::Remove(JSThread *thread, JSHandle<JSTaggedVal
|
||||
{
|
||||
uint32_t size = GetLength();
|
||||
TaggedArray *valueArray = TaggedArray::Cast(GetValues().GetTaggedObject());
|
||||
int32_t index = GetHashIndex(value, size);
|
||||
int32_t index = GetHashIndex(thread, value, size);
|
||||
if (index < 0) {
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
@ -446,7 +446,7 @@ void JSAPILightWeightSet::Clear(JSThread *thread)
|
||||
SetLength(0);
|
||||
}
|
||||
|
||||
uint32_t JSAPILightWeightSet::Hash(JSTaggedValue key)
|
||||
uint32_t JSAPILightWeightSet::Hash(const JSThread *thread, JSTaggedValue key)
|
||||
{
|
||||
if (key.IsDouble() && key.GetDouble() == 0.0) {
|
||||
key = JSTaggedValue(0);
|
||||
@ -463,9 +463,8 @@ uint32_t JSAPILightWeightSet::Hash(JSTaggedValue key)
|
||||
uint32_t hash = ECMAObject::Cast(key.GetTaggedObject())->GetHash();
|
||||
if (hash == 0) {
|
||||
hash = static_cast<uint32_t>(base::RandomGenerator::GenerateIdentityHash());
|
||||
JSThread *thread = ECMAObject::Cast(key.GetTaggedObject())->GetJSThread();
|
||||
JSHandle<ECMAObject> ecmaObj(thread, key);
|
||||
ECMAObject::SetHash(hash, ecmaObj);
|
||||
ECMAObject::SetHash(thread, hash, ecmaObj);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -52,17 +52,17 @@ public:
|
||||
JSTaggedValue GetHashAt(int32_t index);
|
||||
JSTaggedValue GetValueAt(int32_t index);
|
||||
JSTaggedValue Remove(JSThread *thread, JSHandle<JSTaggedValue> &value);
|
||||
bool Has(const JSHandle<JSTaggedValue> &value);
|
||||
bool Has(const JSThread *thread, const JSHandle<JSTaggedValue> &value);
|
||||
bool HasHash(const JSHandle<JSTaggedValue> &hashCode);
|
||||
bool HasAll(const JSHandle<JSTaggedValue> &value);
|
||||
bool RemoveAt(JSThread *thread, int32_t index);
|
||||
void RemoveValue(const JSThread *thread, JSHandle<TaggedArray> &taggedArray,
|
||||
uint32_t index);
|
||||
bool IsEmpty();
|
||||
int32_t GetIndexOf(JSHandle<JSTaggedValue> &value);
|
||||
int32_t GetIndexOf(const JSThread *thread, JSHandle<JSTaggedValue> &value);
|
||||
int32_t BinarySearchHashes(uint32_t hash, int32_t size);
|
||||
int32_t GetHashIndex(const JSHandle<JSTaggedValue> &value, int32_t size);
|
||||
uint32_t Hash(JSTaggedValue key);
|
||||
int32_t GetHashIndex(const JSThread *thread, const JSHandle<JSTaggedValue> &value, int32_t size);
|
||||
uint32_t Hash(const JSThread *thread, JSTaggedValue key);
|
||||
inline uint32_t GetSize() const
|
||||
{
|
||||
return GetLength();
|
||||
|
@ -61,8 +61,8 @@ void JSFinalizationRegistry::Register(JSThread *thread, JSHandle<JSTaggedValue>
|
||||
if (!unregisterToken->IsUndefined()) {
|
||||
JSHandle<LinkedHashMap> maybeUnregister(thread, obj->GetMaybeUnregister());
|
||||
JSHandle<CellRecordVector> array(thread, JSTaggedValue::Undefined());
|
||||
if (maybeUnregister->Has(unregisterToken.GetTaggedValue())) {
|
||||
array = JSHandle<CellRecordVector>(thread, maybeUnregister->Get(unregisterToken.GetTaggedValue()));
|
||||
if (maybeUnregister->Has(thread, unregisterToken.GetTaggedValue())) {
|
||||
array = JSHandle<CellRecordVector>(thread, maybeUnregister->Get(thread, unregisterToken.GetTaggedValue()));
|
||||
} else {
|
||||
array = JSHandle<CellRecordVector>(CellRecordVector::Create(thread));
|
||||
}
|
||||
@ -84,7 +84,7 @@ bool JSFinalizationRegistry::Unregister(JSThread *thread, JSHandle<JSTaggedValue
|
||||
// Because we have stored the object that may be unregistered in the hash map when registering,
|
||||
// at this time we just need to find it in the map and delete it
|
||||
JSHandle<LinkedHashMap> maybeUnregister(thread, obj->GetMaybeUnregister());
|
||||
int entry = maybeUnregister->FindElement(UnregisterToken.GetTaggedValue());
|
||||
int entry = maybeUnregister->FindElement(thread, UnregisterToken.GetTaggedValue());
|
||||
if (entry == -1) {
|
||||
return false;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public:
|
||||
auto hclass = JSHandle<JSHClass>(thread, protoHandle->GetTaggedObject()->GetClass());
|
||||
JSHandle<JSHClass> newJSHClass = JSHClass::Clone(thread, hclass);
|
||||
newJSHClass->SetIsPrototype(true);
|
||||
protoHandle->GetTaggedObject()->SynchronizedSetClass(*newJSHClass);
|
||||
protoHandle->GetTaggedObject()->SynchronizedSetClass(thread, *newJSHClass);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ void JSHClass::AddProperty(const JSThread *thread, const JSHandle<JSObject> &obj
|
||||
if (newClass->IsTS()) {
|
||||
newClass->SetPrototype(thread, jshclass->GetPrototype());
|
||||
}
|
||||
obj->SynchronizedSetClass(newClass);
|
||||
obj->SynchronizedSetClass(thread, newClass);
|
||||
// Because we currently only supports Fast ElementsKind
|
||||
JSHandle<JSHClass> newHClass(thread, newClass);
|
||||
TryRestoreElementsKind(thread, newHClass, obj);
|
||||
@ -260,7 +260,7 @@ void JSHClass::AddProperty(const JSThread *thread, const JSHandle<JSObject> &obj
|
||||
#if ECMASCRIPT_ENABLE_IC
|
||||
JSHClass::NotifyHclassChanged(thread, jshclass, newJsHClass, key.GetTaggedValue());
|
||||
#endif
|
||||
obj->SynchronizedSetClass(*newJsHClass);
|
||||
obj->SynchronizedSetClass(thread, *newJsHClass);
|
||||
// Because we currently only supports Fast ElementsKind
|
||||
TryRestoreElementsKind(thread, newJsHClass, obj);
|
||||
|
||||
@ -410,7 +410,7 @@ void JSHClass::ShouldUpdateProtoClass(const JSThread *thread, const JSHandle<JST
|
||||
// After the hclass is updated, check whether the proto chain status of ic is updated.
|
||||
NotifyHclassChanged(thread, hclass, newProtoClass);
|
||||
#endif
|
||||
JSObject::Cast(proto->GetTaggedObject())->SynchronizedSetClass(*newProtoClass);
|
||||
JSObject::Cast(proto->GetTaggedObject())->SynchronizedSetClass(thread, *newProtoClass);
|
||||
newProtoClass->SetIsPrototype(true);
|
||||
thread->GetEcmaVM()->GetPGOProfiler()->UpdateRootProfileType(*hclass, *newProtoClass);
|
||||
} else {
|
||||
@ -437,7 +437,7 @@ void JSHClass::TransitionToDictionary(const JSThread *thread, const JSHandle<JSO
|
||||
#if ECMASCRIPT_ENABLE_IC
|
||||
JSHClass::NotifyHclassChanged(thread, JSHandle<JSHClass>(thread, obj->GetJSHClass()), newJsHClass);
|
||||
#endif
|
||||
obj->SynchronizedSetClass(*newJsHClass);
|
||||
obj->SynchronizedSetClass(thread, *newJsHClass);
|
||||
TryRestoreElementsKind(thread, newJsHClass, obj);
|
||||
}
|
||||
}
|
||||
@ -484,7 +484,7 @@ void JSHClass::OptimizeAsFastProperties(const JSThread *thread, const JSHandle<J
|
||||
#if ECMASCRIPT_ENABLE_IC
|
||||
JSHClass::NotifyHclassChanged(thread, JSHandle<JSHClass>(thread, obj->GetJSHClass()), newJsHClass);
|
||||
#endif
|
||||
obj->SynchronizedSetClass(*newJsHClass);
|
||||
obj->SynchronizedSetClass(thread, *newJsHClass);
|
||||
}
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ void JSHClass::TransitionForRepChange(const JSThread *thread, const JSHandle<JSO
|
||||
JSHClass::NotifyHclassChanged(thread, oldHClass, newHClass, key.GetTaggedValue());
|
||||
#endif
|
||||
|
||||
receiver->SynchronizedSetClass(*newHClass);
|
||||
receiver->SynchronizedSetClass(thread, *newHClass);
|
||||
TryRestoreElementsKind(thread, newHClass, receiver);
|
||||
// 4. Maybe Transition And Maintain subtypeing check
|
||||
}
|
||||
@ -550,7 +550,7 @@ void JSHClass::TransitToElementsKind(const JSThread *thread, const JSHandle<JSAr
|
||||
auto index = static_cast<size_t>(newKindIter->second);
|
||||
auto hclassVal = thread->GlobalConstants()->GetGlobalConstantObject(index);
|
||||
JSHClass *hclass = JSHClass::Cast(hclassVal.GetTaggedObject());
|
||||
array->SynchronizedSetClass(hclass);
|
||||
array->SynchronizedSetClass(thread, hclass);
|
||||
}
|
||||
}
|
||||
|
||||
@ -578,7 +578,7 @@ bool JSHClass::TransitToElementsKind(const JSThread *thread, const JSHandle<JSOb
|
||||
auto index = static_cast<size_t>(newKindIter->second);
|
||||
auto hclassVal = thread->GlobalConstants()->GetGlobalConstantObject(index);
|
||||
JSHClass *hclass = JSHClass::Cast(hclassVal.GetTaggedObject());
|
||||
object->SynchronizedSetClass(hclass);
|
||||
object->SynchronizedSetClass(thread, hclass);
|
||||
// Update TrackInfo
|
||||
if (!thread->IsPGOProfilerEnable()) {
|
||||
return true;
|
||||
|
@ -35,7 +35,7 @@ void JSMap::Set(JSThread *thread, const JSHandle<JSMap> &map, const JSHandle<JST
|
||||
bool JSMap::Delete(const JSThread *thread, const JSHandle<JSMap> &map, const JSHandle<JSTaggedValue> &key)
|
||||
{
|
||||
JSHandle<LinkedHashMap> mapHandle(thread, LinkedHashMap::Cast(map->GetLinkedMap().GetTaggedObject()));
|
||||
int entry = mapHandle->FindElement(key.GetTaggedValue());
|
||||
int entry = mapHandle->FindElement(thread, key.GetTaggedValue());
|
||||
if (entry == -1) {
|
||||
return false;
|
||||
}
|
||||
@ -51,14 +51,14 @@ void JSMap::Clear(const JSThread *thread, const JSHandle<JSMap> &map)
|
||||
map->SetLinkedMap(thread, newMap);
|
||||
}
|
||||
|
||||
bool JSMap::Has(JSTaggedValue key) const
|
||||
bool JSMap::Has(JSThread *thread, JSTaggedValue key) const
|
||||
{
|
||||
return LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject())->Has(key);
|
||||
return LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject())->Has(thread, key);
|
||||
}
|
||||
|
||||
JSTaggedValue JSMap::Get(JSTaggedValue key) const
|
||||
JSTaggedValue JSMap::Get(JSThread *thread, JSTaggedValue key) const
|
||||
{
|
||||
return LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject())->Get(key);
|
||||
return LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject())->Get(thread, key);
|
||||
}
|
||||
|
||||
uint32_t JSMap::GetSize() const
|
||||
|
@ -30,9 +30,9 @@ public:
|
||||
const JSHandle<JSTaggedValue> &value);
|
||||
static void Clear(const JSThread *thread, const JSHandle<JSMap> &map);
|
||||
|
||||
bool Has(JSTaggedValue key) const;
|
||||
bool Has(JSThread *thread, JSTaggedValue key) const;
|
||||
|
||||
JSTaggedValue Get(JSTaggedValue key) const;
|
||||
JSTaggedValue Get(JSThread *thread, JSTaggedValue key) const;
|
||||
|
||||
uint32_t GetSize() const;
|
||||
|
||||
|
@ -1411,7 +1411,7 @@ bool JSObject::SetPrototype(JSThread *thread, const JSHandle<JSObject> &obj, con
|
||||
JSHandle<JSHClass> hclass(thread, obj->GetJSHClass());
|
||||
JSHandle<JSHClass> newClass = JSHClass::TransitionProto(thread, hclass, proto);
|
||||
JSHClass::NotifyHclassChanged(thread, hclass, newClass);
|
||||
obj->SynchronizedSetClass(*newClass);
|
||||
obj->SynchronizedSetClass(thread, *newClass);
|
||||
JSHClass::TryRestoreElementsKind(thread, newClass, obj);
|
||||
thread->NotifyStableArrayElementsGuardians(obj, StableArrayChangeKind::PROTO);
|
||||
ObjectOperator::UpdateDetectorOnSetPrototype(thread, obj.GetTaggedValue());
|
||||
@ -1451,7 +1451,7 @@ bool JSObject::PreventExtensions(JSThread *thread, const JSHandle<JSObject> &obj
|
||||
if (obj->IsExtensible()) {
|
||||
JSHandle<JSHClass> jshclass(thread, obj->GetJSHClass());
|
||||
JSHandle<JSHClass> newHclass = JSHClass::TransitionExtension(thread, jshclass);
|
||||
obj->SynchronizedSetClass(*newHclass);
|
||||
obj->SynchronizedSetClass(thread, *newHclass);
|
||||
JSHClass::TryRestoreElementsKind(thread, newHclass, obj);
|
||||
}
|
||||
|
||||
@ -2663,12 +2663,11 @@ void JSObject::TrimInlinePropsSpace(const JSThread *thread, const JSHandle<JSObj
|
||||
}
|
||||
|
||||
// The hash field may be a hash value, FunctionExtraInfo(JSNativePointer) or TaggedArray
|
||||
void ECMAObject::SetHash(int32_t hash, const JSHandle<ECMAObject> &obj)
|
||||
void ECMAObject::SetHash(const JSThread *thread, int32_t hash, const JSHandle<ECMAObject> &obj)
|
||||
{
|
||||
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(*obj, HASH_OFFSET);
|
||||
JSTaggedValue value(hashField);
|
||||
if (value.IsHeapObject()) {
|
||||
JSThread *thread = (*obj)->GetJSThread();
|
||||
// Hash position reserve in advance.
|
||||
if (value.IsTaggedArray()) {
|
||||
TaggedArray *array = TaggedArray::Cast(value.GetTaggedObject());
|
||||
@ -2720,23 +2719,21 @@ void *ECMAObject::GetNativePointerField(int32_t index) const
|
||||
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
|
||||
JSTaggedValue value(hashField);
|
||||
if (value.IsTaggedArray()) {
|
||||
JSThread *thread = this->GetJSThread();
|
||||
JSHandle<TaggedArray> array(thread, value);
|
||||
auto array = TaggedArray::Cast(value);
|
||||
if (static_cast<int32_t>(array->GetExtraLength()) > index) {
|
||||
JSHandle<JSNativePointer> pointer(thread, array->Get(index));
|
||||
auto pointer = JSNativePointer::Cast(array->Get(index).GetTaggedObject());
|
||||
return pointer->GetExternalPointer();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ECMAObject::SetNativePointerField(int32_t index, void *nativePointer,
|
||||
void ECMAObject::SetNativePointerField(const JSThread *thread, int32_t index, void *nativePointer,
|
||||
const DeleteEntryPoint &callBack, void *data, size_t nativeBindingsize)
|
||||
{
|
||||
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
|
||||
JSTaggedValue value(hashField);
|
||||
if (value.IsTaggedArray()) {
|
||||
JSThread *thread = this->GetJSThread();
|
||||
JSHandle<TaggedArray> array(thread, value);
|
||||
if (static_cast<int32_t>(array->GetExtraLength()) > index) {
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
@ -2766,13 +2763,12 @@ int32_t ECMAObject::GetNativePointerFieldCount() const
|
||||
return len;
|
||||
}
|
||||
|
||||
void ECMAObject::SetNativePointerFieldCount(int32_t count)
|
||||
void ECMAObject::SetNativePointerFieldCount(const JSThread *thread, int32_t count)
|
||||
{
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
JSTaggedType hashField = Barriers::GetValue<JSTaggedType>(this, HASH_OFFSET);
|
||||
JSThread *thread = this->GetJSThread();
|
||||
JSHandle<JSTaggedValue> value(thread, JSTaggedValue(hashField));
|
||||
JSHandle<ECMAObject> obj(thread, this);
|
||||
if (value->IsHeapObject()) {
|
||||
|
@ -372,7 +372,7 @@ public:
|
||||
static constexpr size_t HASH_OFFSET = TaggedObjectSize();
|
||||
static constexpr size_t SIZE = HASH_OFFSET + sizeof(JSTaggedType);
|
||||
|
||||
static void SetHash(int32_t hash, const JSHandle<ECMAObject> &obj);
|
||||
static void SetHash(const JSThread *thread, int32_t hash, const JSHandle<ECMAObject> &obj);
|
||||
int32_t GetHash() const;
|
||||
bool HasHash() const;
|
||||
|
||||
@ -382,10 +382,10 @@ public:
|
||||
}
|
||||
|
||||
void* GetNativePointerField(int32_t index) const;
|
||||
void SetNativePointerField(int32_t index, void *nativePointer,
|
||||
void SetNativePointerField(const JSThread *thread, int32_t index, void *nativePointer,
|
||||
const DeleteEntryPoint &callBack, void *data, size_t nativeBindingsize = 0);
|
||||
int32_t GetNativePointerFieldCount() const;
|
||||
void SetNativePointerFieldCount(int32_t count);
|
||||
void SetNativePointerFieldCount(const JSThread *thread, int32_t count);
|
||||
|
||||
DECL_VISIT_OBJECT(HASH_OFFSET, SIZE);
|
||||
|
||||
|
@ -35,7 +35,7 @@ void JSSet::Add(JSThread *thread, const JSHandle<JSSet> &set, const JSHandle<JST
|
||||
bool JSSet::Delete(const JSThread *thread, const JSHandle<JSSet> &set, const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
JSHandle<LinkedHashSet> setHandle(thread, LinkedHashSet::Cast(set->GetLinkedSet().GetTaggedObject()));
|
||||
int entry = setHandle->FindElement(value.GetTaggedValue());
|
||||
int entry = setHandle->FindElement(thread, value.GetTaggedValue());
|
||||
if (entry == -1) {
|
||||
return false;
|
||||
}
|
||||
@ -51,9 +51,9 @@ void JSSet::Clear(const JSThread *thread, const JSHandle<JSSet> &set)
|
||||
set->SetLinkedSet(thread, newSet);
|
||||
}
|
||||
|
||||
bool JSSet::Has(JSTaggedValue value) const
|
||||
bool JSSet::Has(const JSThread *thread, JSTaggedValue value) const
|
||||
{
|
||||
return LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject())->Has(value);
|
||||
return LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject())->Has(thread, value);
|
||||
}
|
||||
|
||||
uint32_t JSSet::GetSize() const
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
|
||||
static void Clear(const JSThread *thread, const JSHandle<JSSet> &set);
|
||||
|
||||
bool Has(JSTaggedValue value) const;
|
||||
bool Has(const JSThread *thread, JSTaggedValue value) const;
|
||||
|
||||
uint32_t GetSize() const;
|
||||
|
||||
|
@ -338,6 +338,11 @@ public:
|
||||
MarkStatusBits::Set(status, &glueData_.gcStateBitField_);
|
||||
}
|
||||
|
||||
bool IsConcurrentMarkingOrFinished() const
|
||||
{
|
||||
return !IsReadyToMark();
|
||||
}
|
||||
|
||||
bool IsReadyToMark() const
|
||||
{
|
||||
auto status = MarkStatusBits::Decode(glueData_.gcStateBitField_);
|
||||
|
@ -36,7 +36,7 @@ void JSWeakMap::Set(JSThread *thread, const JSHandle<JSWeakMap> &map, const JSHa
|
||||
bool JSWeakMap::Delete(JSThread *thread, const JSHandle<JSWeakMap> &map, const JSHandle<JSTaggedValue> &key)
|
||||
{
|
||||
JSHandle<LinkedHashMap> mapHandle(thread, LinkedHashMap::Cast(map->GetLinkedMap().GetTaggedObject()));
|
||||
int entry = mapHandle->FindElement(key.GetTaggedValue());
|
||||
int entry = mapHandle->FindElement(thread, key.GetTaggedValue());
|
||||
if (entry == -1) {
|
||||
return false;
|
||||
}
|
||||
@ -47,14 +47,14 @@ bool JSWeakMap::Delete(JSThread *thread, const JSHandle<JSWeakMap> &map, const J
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JSWeakMap::Has(JSTaggedValue key) const
|
||||
bool JSWeakMap::Has(JSThread *thread, JSTaggedValue key) const
|
||||
{
|
||||
return LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject())->Has(key);
|
||||
return LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject())->Has(thread, key);
|
||||
}
|
||||
|
||||
JSTaggedValue JSWeakMap::Get(JSTaggedValue key) const
|
||||
JSTaggedValue JSWeakMap::Get(JSThread *thread, JSTaggedValue key) const
|
||||
{
|
||||
return LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject())->Get(key);
|
||||
return LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject())->Get(thread, key);
|
||||
}
|
||||
|
||||
int JSWeakMap::GetSize() const
|
||||
@ -88,7 +88,7 @@ void JSWeakSet::Add(JSThread *thread, const JSHandle<JSWeakSet> &weakSet, const
|
||||
bool JSWeakSet::Delete(JSThread *thread, const JSHandle<JSWeakSet> &weakSet, const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
JSHandle<LinkedHashSet> weakSetHandle(thread, LinkedHashSet::Cast(weakSet->GetLinkedSet().GetTaggedObject()));
|
||||
int entry = weakSetHandle->FindElement(value.GetTaggedValue());
|
||||
int entry = weakSetHandle->FindElement(thread, value.GetTaggedValue());
|
||||
if (entry == -1) {
|
||||
return false;
|
||||
}
|
||||
@ -98,9 +98,9 @@ bool JSWeakSet::Delete(JSThread *thread, const JSHandle<JSWeakSet> &weakSet, con
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JSWeakSet::Has(JSTaggedValue value) const
|
||||
bool JSWeakSet::Has(JSThread *thread, JSTaggedValue value) const
|
||||
{
|
||||
return LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject())->Has(value);
|
||||
return LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject())->Has(thread, value);
|
||||
}
|
||||
|
||||
int JSWeakSet::GetSize() const
|
||||
|
@ -32,9 +32,9 @@ public:
|
||||
static void Set(JSThread *thread, const JSHandle<JSWeakMap> &map, const JSHandle<JSTaggedValue> &key,
|
||||
const JSHandle<JSTaggedValue> &value);
|
||||
|
||||
bool Has(JSTaggedValue key) const;
|
||||
bool Has(JSThread *thread, JSTaggedValue key) const;
|
||||
|
||||
JSTaggedValue Get(JSTaggedValue key) const;
|
||||
JSTaggedValue Get(JSThread *thread, JSTaggedValue key) const;
|
||||
|
||||
int GetSize() const;
|
||||
|
||||
@ -60,7 +60,7 @@ public:
|
||||
|
||||
static void Add(JSThread *thread, const JSHandle<JSWeakSet> &set, const JSHandle<JSTaggedValue> &value);
|
||||
|
||||
bool Has(JSTaggedValue value) const;
|
||||
bool Has(JSThread *thread, JSTaggedValue value) const;
|
||||
|
||||
int GetSize() const;
|
||||
|
||||
|
@ -388,7 +388,7 @@ public:
|
||||
auto globalConstant = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
|
||||
auto classIndex = static_cast<size_t>(ConstantIndex::ELEMENT_NONE_HCLASS_INDEX);
|
||||
auto hclassVal = globalConstant->GetGlobalConstantObject(classIndex);
|
||||
arr->SynchronizedSetClass(JSHClass::Cast(hclassVal.GetTaggedObject()));
|
||||
arr->SynchronizedSetClass(thread, JSHClass::Cast(hclassVal.GetTaggedObject()));
|
||||
ElementsKind oldKind = arr->GetClass()->GetElementsKind();
|
||||
JSHClass::TransitToElementsKind(thread, arr, dataKind);
|
||||
ElementsKind newKind = arr->GetClass()->GetElementsKind();
|
||||
|
@ -41,8 +41,8 @@ JSHandle<Derived> LinkedHashTable<Derived, HashObject>::Insert(const JSThread *t
|
||||
const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
ASSERT(IsKey(key.GetTaggedValue()));
|
||||
int hash = LinkedHash::Hash(key.GetTaggedValue());
|
||||
int entry = table->FindElement(key.GetTaggedValue());
|
||||
int hash = LinkedHash::Hash(thread, key.GetTaggedValue());
|
||||
int entry = table->FindElement(thread, key.GetTaggedValue());
|
||||
if (entry != -1) {
|
||||
table->SetValue(thread, entry, value.GetTaggedValue());
|
||||
return table;
|
||||
@ -65,8 +65,8 @@ JSHandle<Derived> LinkedHashTable<Derived, HashObject>::InsertWeakRef(const JSTh
|
||||
const JSHandle<Derived> &table, const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
ASSERT(IsKey(key.GetTaggedValue()));
|
||||
int hash = LinkedHash::Hash(key.GetTaggedValue());
|
||||
int entry = table->FindElement(key.GetTaggedValue());
|
||||
int hash = LinkedHash::Hash(thread, key.GetTaggedValue());
|
||||
int entry = table->FindElement(thread, key.GetTaggedValue());
|
||||
if (entry != -1) {
|
||||
table->SetValue(thread, entry, value.GetTaggedValue());
|
||||
return table;
|
||||
@ -105,7 +105,7 @@ template<typename Derived, typename HashObject>
|
||||
JSHandle<Derived> LinkedHashTable<Derived, HashObject>::Remove(const JSThread *thread, const JSHandle<Derived> &table,
|
||||
const JSHandle<JSTaggedValue> &key)
|
||||
{
|
||||
int entry = table->FindElement(key.GetTaggedValue());
|
||||
int entry = table->FindElement(thread, key.GetTaggedValue());
|
||||
if (entry == -1) {
|
||||
return table;
|
||||
}
|
||||
@ -153,18 +153,18 @@ JSHandle<LinkedHashMap> LinkedHashMap::SetWeakRef(const JSThread *thread, const
|
||||
return LinkedHashTable<LinkedHashMap, LinkedHashMapObject>::InsertWeakRef(thread, obj, key, value);
|
||||
}
|
||||
|
||||
JSTaggedValue LinkedHashMap::Get(JSTaggedValue key) const
|
||||
JSTaggedValue LinkedHashMap::Get(const JSThread *thread, JSTaggedValue key) const
|
||||
{
|
||||
int entry = FindElement(key);
|
||||
int entry = FindElement(thread, key);
|
||||
if (entry == -1) {
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
return GetValue(entry);
|
||||
}
|
||||
|
||||
bool LinkedHashMap::Has(JSTaggedValue key) const
|
||||
bool LinkedHashMap::Has(const JSThread *thread, JSTaggedValue key) const
|
||||
{
|
||||
int entry = FindElement(key);
|
||||
int entry = FindElement(thread, key);
|
||||
return entry != -1;
|
||||
}
|
||||
|
||||
@ -208,9 +208,9 @@ JSHandle<LinkedHashSet> LinkedHashSet::AddWeakRef(const JSThread *thread, const
|
||||
return LinkedHashTable<LinkedHashSet, LinkedHashSetObject>::InsertWeakRef(thread, obj, key, key);
|
||||
}
|
||||
|
||||
bool LinkedHashSet::Has(JSTaggedValue key) const
|
||||
bool LinkedHashSet::Has(const JSThread *thread, JSTaggedValue key) const
|
||||
{
|
||||
int entry = FindElement(key);
|
||||
int entry = FindElement(thread, key);
|
||||
return entry != -1;
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ JSHandle<LinkedHashSet> LinkedHashSet::Shrink(const JSThread *thread, const JSHa
|
||||
return LinkedHashTable<LinkedHashSet, LinkedHashSetObject>::Shrink(thread, table, additionalCapacity);
|
||||
}
|
||||
|
||||
int LinkedHash::Hash(JSTaggedValue key)
|
||||
int LinkedHash::Hash(const JSThread *thread, JSTaggedValue key)
|
||||
{
|
||||
if (key.IsSymbol()) {
|
||||
auto symbolString = JSSymbol::Cast(key.GetTaggedObject());
|
||||
@ -244,9 +244,8 @@ int LinkedHash::Hash(JSTaggedValue key)
|
||||
int32_t hash = ECMAObject::Cast(key.GetTaggedObject())->GetHash();
|
||||
if (hash == 0) {
|
||||
hash = base::RandomGenerator::GenerateIdentityHash();
|
||||
JSThread *thread = ECMAObject::Cast(key.GetTaggedObject())->GetJSThread();
|
||||
JSHandle<ECMAObject> ecmaObj(thread, key);
|
||||
ECMAObject::SetHash(hash, ecmaObj);
|
||||
ECMAObject::SetHash(thread, hash, ecmaObj);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
namespace panda::ecmascript {
|
||||
class LinkedHash {
|
||||
public:
|
||||
static int Hash(JSTaggedValue key);
|
||||
static int Hash(const JSThread *thread, JSTaggedValue key);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -81,12 +81,12 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
inline int FindElement(JSTaggedValue key) const
|
||||
inline int FindElement(const JSThread *thread, JSTaggedValue key) const
|
||||
{
|
||||
if (!IsKey(key)) {
|
||||
return -1;
|
||||
}
|
||||
int hash = LinkedHash::Hash(key);
|
||||
int hash = LinkedHash::Hash(thread, key);
|
||||
uint32_t bucket = HashToBucket(hash);
|
||||
for (JSTaggedValue entry = GetElement(BucketToIndex(bucket)); !entry.IsHole();
|
||||
entry = GetNextEntry(entry.GetInt())) {
|
||||
@ -237,7 +237,7 @@ public:
|
||||
key.RemoveWeakTag();
|
||||
}
|
||||
|
||||
int bucket = static_cast<int>(newTable->HashToBucket(LinkedHash::Hash(key)));
|
||||
int bucket = static_cast<int>(newTable->HashToBucket(LinkedHash::Hash(thread, key)));
|
||||
newTable->InsertNewEntry(thread, bucket, desEntry);
|
||||
int desIndex = static_cast<int>(newTable->EntryToIndex(desEntry));
|
||||
for (int j = 0; j < HashObject::ENTRY_SIZE; j++) {
|
||||
@ -352,12 +352,12 @@ public:
|
||||
static JSHandle<LinkedHashMap> SetWeakRef(const JSThread *thread, const JSHandle<LinkedHashMap> &obj,
|
||||
const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &value);
|
||||
|
||||
JSTaggedValue Get(JSTaggedValue key) const;
|
||||
JSTaggedValue Get(const JSThread *thread, JSTaggedValue key) const;
|
||||
|
||||
static JSHandle<LinkedHashMap> Shrink(const JSThread *thread, const JSHandle<LinkedHashMap> &table,
|
||||
int additionalCapacity = 0);
|
||||
|
||||
bool Has(JSTaggedValue key) const;
|
||||
bool Has(const JSThread *thread, JSTaggedValue key) const;
|
||||
|
||||
static JSHandle<LinkedHashMap> Clear(const JSThread *thread, const JSHandle<LinkedHashMap> &table);
|
||||
DECL_DUMP()
|
||||
@ -395,7 +395,7 @@ public:
|
||||
static JSHandle<LinkedHashSet> Shrink(const JSThread *thread, const JSHandle<LinkedHashSet> &table,
|
||||
int additionalCapacity = 0);
|
||||
|
||||
bool Has(JSTaggedValue key) const;
|
||||
bool Has(const JSThread *thread, JSTaggedValue key) const;
|
||||
|
||||
static JSHandle<LinkedHashSet> Clear(const JSThread *thread, const JSHandle<LinkedHashSet> &table);
|
||||
DECL_DUMP()
|
||||
|
@ -24,13 +24,13 @@
|
||||
#include "ecmascript/ecma_vm.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
static ARK_INLINE void WriteBarrier(void *obj, size_t offset, JSTaggedType value)
|
||||
static ARK_INLINE void WriteBarrier(const JSThread *thread, void *obj, size_t offset, JSTaggedType value)
|
||||
{
|
||||
ASSERT(value != JSTaggedValue::VALUE_UNDEFINED);
|
||||
Region *objectRegion = Region::ObjectAddressToRange(static_cast<TaggedObject *>(obj));
|
||||
Region *valueRegion = Region::ObjectAddressToRange(reinterpret_cast<TaggedObject *>(value));
|
||||
#if ECMASCRIPT_ENABLE_BARRIER_CHECK
|
||||
if (!valueRegion->GetJSThread()->GetEcmaVM()->GetHeap()->IsAlive(JSTaggedValue(value).GetHeapObject())) {
|
||||
if (!thread->GetEcmaVM()->GetHeap()->IsAlive(JSTaggedValue(value).GetHeapObject())) {
|
||||
LOG_FULL(FATAL) << "WriteBarrier checked value:" << value << " is invalid!";
|
||||
}
|
||||
#endif
|
||||
@ -41,8 +41,8 @@ static ARK_INLINE void WriteBarrier(void *obj, size_t offset, JSTaggedType value
|
||||
objectRegion->InsertOldToNewRSet(slotAddr);
|
||||
}
|
||||
|
||||
if (valueRegion->IsMarking()) {
|
||||
Barriers::Update(slotAddr, objectRegion, reinterpret_cast<TaggedObject *>(value), valueRegion);
|
||||
if (thread->IsConcurrentMarkingOrFinished()) {
|
||||
Barriers::Update(thread, slotAddr, objectRegion, reinterpret_cast<TaggedObject *>(value), valueRegion);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,25 +50,26 @@ static ARK_INLINE void WriteBarrier(void *obj, size_t offset, JSTaggedType value
|
||||
// CODECHECK-NOLINTNEXTLINE(C_RULE_ID_COMMENT_LOCATION)
|
||||
// default value for need_write_barrier is true
|
||||
template<bool need_write_barrier>
|
||||
inline void Barriers::SetObject([[maybe_unused]] const JSThread *thread, void *obj, size_t offset, JSTaggedType value)
|
||||
inline void Barriers::SetObject(const JSThread *thread, void *obj, size_t offset, JSTaggedType value)
|
||||
{
|
||||
// NOLINTNEXTLINE(clang-analyzer-core.NullDereference)
|
||||
*reinterpret_cast<JSTaggedType *>(reinterpret_cast<uintptr_t>(obj) + offset) = value;
|
||||
WriteBarrier(obj, offset, value);
|
||||
WriteBarrier(thread, obj, offset, value);
|
||||
}
|
||||
|
||||
inline void Barriers::SynchronizedSetClass(void *obj, JSTaggedType value)
|
||||
inline void Barriers::SynchronizedSetClass(const JSThread *thread, void *obj, JSTaggedType value)
|
||||
{
|
||||
reinterpret_cast<volatile std::atomic<JSTaggedType> *>(obj)->store(value, std::memory_order_release);
|
||||
WriteBarrier(obj, 0, value);
|
||||
WriteBarrier(thread, obj, 0, value);
|
||||
}
|
||||
|
||||
inline void Barriers::SynchronizedSetObject(void *obj, size_t offset, JSTaggedType value, bool isPrimitive)
|
||||
inline void Barriers::SynchronizedSetObject(const JSThread *thread, void *obj, size_t offset, JSTaggedType value,
|
||||
bool isPrimitive)
|
||||
{
|
||||
reinterpret_cast<volatile std::atomic<JSTaggedType> *>(ToUintPtr(obj) + offset)
|
||||
->store(value, std::memory_order_release);
|
||||
if (!isPrimitive) {
|
||||
WriteBarrier(obj, offset, value);
|
||||
WriteBarrier(thread, obj, offset, value);
|
||||
}
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -18,9 +18,9 @@
|
||||
#include "ecmascript/mem/heap.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
void Barriers::Update(uintptr_t slotAddr, Region *objectRegion, TaggedObject *value, Region *valueRegion)
|
||||
void Barriers::Update(const JSThread *thread, uintptr_t slotAddr, Region *objectRegion, TaggedObject *value,
|
||||
Region *valueRegion)
|
||||
{
|
||||
JSThread *thread = valueRegion->GetJSThread();
|
||||
auto heap = thread->GetEcmaVM()->GetHeap();
|
||||
if (heap->IsFullMark()) {
|
||||
if (valueRegion->InCollectSet() && !objectRegion->InYoungSpaceOrCSet()) {
|
||||
|
@ -44,8 +44,9 @@ public:
|
||||
template<bool need_write_barrier = true>
|
||||
static void SetObject(const JSThread *thread, void *obj, size_t offset, JSTaggedType value);
|
||||
|
||||
static void SynchronizedSetClass(void *obj, JSTaggedType value);
|
||||
static void SynchronizedSetObject(void *obj, size_t offset, JSTaggedType value, bool isPrimitive = false);
|
||||
static void SynchronizedSetClass(const JSThread *thread, void *obj, JSTaggedType value);
|
||||
static void SynchronizedSetObject(const JSThread *thread, void *obj, size_t offset, JSTaggedType value,
|
||||
bool isPrimitive = false);
|
||||
|
||||
template<class T>
|
||||
static inline T GetValue(const void *obj, size_t offset)
|
||||
@ -54,7 +55,8 @@ public:
|
||||
return *addr;
|
||||
}
|
||||
|
||||
static void PUBLIC_API Update(uintptr_t slotAddr, Region *objectRegion, TaggedObject *value, Region *valueRegion);
|
||||
static void PUBLIC_API Update(const JSThread *thread, uintptr_t slotAddr, Region *objectRegion,
|
||||
TaggedObject *value, Region *valueRegion);
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
|
@ -155,7 +155,7 @@ TaggedObject *Heap::AllocateYoungOrHugeObject(size_t size)
|
||||
TaggedObject *Heap::AllocateYoungOrHugeObject(JSHClass *hclass, size_t size)
|
||||
{
|
||||
auto object = AllocateYoungOrHugeObject(size);
|
||||
object->SetClass(hclass);
|
||||
object->SetClass(thread_, hclass);
|
||||
OnAllocateEvent(reinterpret_cast<TaggedObject*>(object), size);
|
||||
return object;
|
||||
}
|
||||
@ -183,7 +183,7 @@ TaggedObject *Heap::TryAllocateYoungGeneration(JSHClass *hclass, size_t size)
|
||||
}
|
||||
auto object = reinterpret_cast<TaggedObject *>(activeSemiSpace_->Allocate(size));
|
||||
if (object != nullptr) {
|
||||
object->SetClass(hclass);
|
||||
object->SetClass(thread_, hclass);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
@ -202,7 +202,7 @@ TaggedObject *Heap::AllocateOldOrHugeObject(JSHClass *hclass, size_t size)
|
||||
}
|
||||
auto object = reinterpret_cast<TaggedObject *>(oldSpace_->Allocate(size));
|
||||
CHECK_OBJ_AND_THROW_OOM_ERROR(object, size, oldSpace_, "Heap::AllocateOldOrHugeObject");
|
||||
object->SetClass(hclass);
|
||||
object->SetClass(thread_, hclass);
|
||||
OnAllocateEvent(reinterpret_cast<TaggedObject*>(object), size);
|
||||
return object;
|
||||
}
|
||||
@ -221,7 +221,7 @@ TaggedObject *Heap::AllocateReadOnlyOrHugeObject(JSHClass *hclass, size_t size)
|
||||
}
|
||||
auto object = reinterpret_cast<TaggedObject *>(readOnlySpace_->Allocate(size));
|
||||
CHECK_OBJ_AND_THROW_OOM_ERROR(object, size, readOnlySpace_, "Heap::AllocateReadOnlyOrHugeObject");
|
||||
object->SetClass(hclass);
|
||||
object->SetClass(thread_, hclass);
|
||||
OnAllocateEvent(reinterpret_cast<TaggedObject*>(object), size);
|
||||
return object;
|
||||
}
|
||||
@ -240,7 +240,7 @@ TaggedObject *Heap::AllocateNonMovableOrHugeObject(JSHClass *hclass, size_t size
|
||||
}
|
||||
auto object = reinterpret_cast<TaggedObject *>(nonMovableSpace_->CheckAndAllocate(size));
|
||||
CHECK_OBJ_AND_THROW_OOM_ERROR(object, size, nonMovableSpace_, "Heap::AllocateNonMovableOrHugeObject");
|
||||
object->SetClass(hclass);
|
||||
object->SetClass(thread_, hclass);
|
||||
OnAllocateEvent(reinterpret_cast<TaggedObject*>(object), size);
|
||||
return object;
|
||||
}
|
||||
@ -287,7 +287,7 @@ TaggedObject *Heap::AllocateHugeObject(JSHClass *hclass, size_t size)
|
||||
// Check whether it is necessary to trigger Old GC before expanding to avoid OOM risk.
|
||||
CheckAndTriggerOldGC(size);
|
||||
auto object = AllocateHugeObject(size);
|
||||
object->SetClass(hclass);
|
||||
object->SetClass(thread_, hclass);
|
||||
OnAllocateEvent(reinterpret_cast<TaggedObject*>(object), size);
|
||||
return object;
|
||||
}
|
||||
@ -305,7 +305,7 @@ TaggedObject *Heap::AllocateMachineCodeObject(JSHClass *hclass, size_t size)
|
||||
reinterpret_cast<TaggedObject *>(AllocateHugeMachineCodeObject(size)) :
|
||||
reinterpret_cast<TaggedObject *>(machineCodeSpace_->Allocate(size));
|
||||
CHECK_OBJ_AND_THROW_OOM_ERROR(object, size, machineCodeSpace_, "Heap::AllocateMachineCodeObject");
|
||||
object->SetClass(hclass);
|
||||
object->SetClass(thread_, hclass);
|
||||
OnAllocateEvent(reinterpret_cast<TaggedObject*>(object), size);
|
||||
return object;
|
||||
}
|
||||
|
@ -243,10 +243,5 @@ inline void Region::DeleteSweepingRSet()
|
||||
sweepingRSet_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool Region::IsMarking() const
|
||||
{
|
||||
return !thread_->IsReadyToMark();
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_MEM_REGION_INL_H
|
||||
|
@ -165,11 +165,6 @@ public:
|
||||
return end_ - packedData_.begin_;
|
||||
}
|
||||
|
||||
JSThread *GetJSThread() const
|
||||
{
|
||||
return thread_;
|
||||
}
|
||||
|
||||
bool IsGCFlagSet(RegionGCFlags flag) const
|
||||
{
|
||||
return (packedData_.flags_.gcFlags_ & flag) == flag;
|
||||
@ -436,8 +431,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsMarking() const;
|
||||
|
||||
void IncreaseAliveObjectSafe(size_t size)
|
||||
{
|
||||
ASSERT(aliveObject_ + size <= GetSize());
|
||||
|
@ -31,14 +31,14 @@ inline void TaggedObject::SetClassWithoutBarrier(JSHClass *hclass)
|
||||
class_ = reinterpret_cast<MarkWordType>(hclass);
|
||||
}
|
||||
|
||||
inline void TaggedObject::SetClass(JSHClass *hclass)
|
||||
inline void TaggedObject::SetClass(const JSThread *thread, JSHClass *hclass)
|
||||
{
|
||||
Barriers::SetObject<true>(GetJSThread(), this, 0, JSTaggedValue(hclass).GetRawData());
|
||||
Barriers::SetObject<true>(thread, this, 0, JSTaggedValue(hclass).GetRawData());
|
||||
}
|
||||
|
||||
inline void TaggedObject::SetClass(JSHandle<JSHClass> hclass)
|
||||
inline void TaggedObject::SetClass(const JSThread *thread, JSHandle<JSHClass> hclass)
|
||||
{
|
||||
SetClass(*hclass);
|
||||
SetClass(thread, *hclass);
|
||||
}
|
||||
|
||||
inline JSHClass *TaggedObject::GetClass() const
|
||||
@ -46,9 +46,9 @@ inline JSHClass *TaggedObject::GetClass() const
|
||||
return reinterpret_cast<JSHClass *>(class_);
|
||||
}
|
||||
|
||||
inline void TaggedObject::SynchronizedSetClass(JSHClass *hclass)
|
||||
inline void TaggedObject::SynchronizedSetClass(const JSThread *thread, JSHClass *hclass)
|
||||
{
|
||||
Barriers::SynchronizedSetClass(this, JSTaggedValue(hclass).GetRawData());
|
||||
Barriers::SynchronizedSetClass(thread, this, JSTaggedValue(hclass).GetRawData());
|
||||
}
|
||||
|
||||
inline JSHClass *TaggedObject::SynchronizedGetClass() const
|
||||
@ -56,13 +56,6 @@ inline JSHClass *TaggedObject::SynchronizedGetClass() const
|
||||
return reinterpret_cast<JSHClass *>(
|
||||
reinterpret_cast<volatile std::atomic<MarkWordType> *>(ToUintPtr(this))->load(std::memory_order_acquire));
|
||||
}
|
||||
|
||||
inline JSThread *TaggedObject::GetJSThread() const
|
||||
{
|
||||
Region *region = Region::ObjectAddressToRange(const_cast<TaggedObject *>(this));
|
||||
ASSERT(region != nullptr);
|
||||
return region->GetJSThread();
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
#endif // ECMASCRIPT_TAGGED_OBJECT_HEADER_INL_H
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
return static_cast<TaggedObject *>(header);
|
||||
}
|
||||
|
||||
void SynchronizedSetClass(JSHClass *hclass);
|
||||
void SynchronizedSetClass(const JSThread *thread, JSHClass *hclass);
|
||||
JSHClass *SynchronizedGetClass() const;
|
||||
void SetClassWithoutBarrier(JSHClass *hclass);
|
||||
JSHClass *GetClass() const;
|
||||
@ -45,11 +45,9 @@ public:
|
||||
static constexpr int HCLASS_OFFSET = 0;
|
||||
static constexpr int SIZE = sizeof(MarkWordType);
|
||||
|
||||
JSThread* GetJSThread() const;
|
||||
|
||||
private:
|
||||
void SetClass(JSHClass *hclass);
|
||||
void SetClass(JSHandle<JSHClass> hclass);
|
||||
void SetClass(const JSThread *thread, JSHClass *hclass);
|
||||
void SetClass(const JSThread *thread, JSHandle<JSHClass> hclass);
|
||||
|
||||
MarkWordType class_;
|
||||
|
||||
|
@ -664,10 +664,11 @@ public:
|
||||
Local<JSValueRef> Freeze(const EcmaVM *vm);
|
||||
Local<JSValueRef> Seal(const EcmaVM *vm);
|
||||
|
||||
void SetNativePointerFieldCount(int32_t count);
|
||||
void SetNativePointerFieldCount(const EcmaVM *vm, int32_t count);
|
||||
int32_t GetNativePointerFieldCount();
|
||||
void *GetNativePointerField(int32_t index);
|
||||
void SetNativePointerField(int32_t index,
|
||||
void SetNativePointerField(const EcmaVM *vm,
|
||||
int32_t index,
|
||||
void *nativePointer = nullptr,
|
||||
NativePointerCallback callBack = nullptr,
|
||||
void *data = nullptr, size_t nativeBindingsize = 0);
|
||||
@ -1347,7 +1348,7 @@ public:
|
||||
Local<JSValueRef> GetValue(const EcmaVM *vm, int entry);
|
||||
static Local<WeakMapRef> New(const EcmaVM *vm);
|
||||
void Set(const EcmaVM *vm, const Local<JSValueRef> &key, const Local<JSValueRef> &value);
|
||||
bool Has(Local<JSValueRef> key);
|
||||
bool Has(const EcmaVM *vm, Local<JSValueRef> key);
|
||||
};
|
||||
|
||||
class ECMA_PUBLIC_API SetRef : public ObjectRef {
|
||||
|
@ -898,7 +898,7 @@ Local<JSValueRef> MapRef::Get(const EcmaVM *vm, Local<JSValueRef> key)
|
||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||
JSHandle<JSMap> map(JSNApiHelper::ToJSHandle(this));
|
||||
return JSNApiHelper::ToLocal<JSValueRef>(JSHandle<JSTaggedValue>(thread,
|
||||
map->Get(JSNApiHelper::ToJSTaggedValue(*key))));
|
||||
map->Get(thread, JSNApiHelper::ToJSTaggedValue(*key))));
|
||||
}
|
||||
|
||||
void MapRef::Set(const EcmaVM *vm, Local<JSValueRef> key, Local<JSValueRef> value)
|
||||
@ -1868,13 +1868,14 @@ Local<JSValueRef> ObjectRef::Seal(const EcmaVM *vm)
|
||||
return scope.Escape(JSNApiHelper::ToLocal<JSValueRef>(resultValue));
|
||||
}
|
||||
|
||||
void ObjectRef::SetNativePointerFieldCount(int32_t count)
|
||||
void ObjectRef::SetNativePointerFieldCount(const EcmaVM *vm, int32_t count)
|
||||
{
|
||||
CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
|
||||
// ObjectRef::New may return special value if exception occurs.
|
||||
// So we need do special value check before use it.
|
||||
DCHECK_SPECIAL_VALUE(this);
|
||||
JSHandle<JSObject> object(JSNApiHelper::ToJSHandle(this));
|
||||
object->SetNativePointerFieldCount(count);
|
||||
object->SetNativePointerFieldCount(thread, count);
|
||||
}
|
||||
|
||||
int32_t ObjectRef::GetNativePointerFieldCount()
|
||||
@ -1895,14 +1896,15 @@ void *ObjectRef::GetNativePointerField(int32_t index)
|
||||
return object->GetNativePointerField(index);
|
||||
}
|
||||
|
||||
void ObjectRef::SetNativePointerField(int32_t index, void *nativePointer,
|
||||
void ObjectRef::SetNativePointerField(const EcmaVM *vm, int32_t index, void *nativePointer,
|
||||
NativePointerCallback callBack, void *data, size_t nativeBindingsize)
|
||||
{
|
||||
CROSS_THREAD_AND_EXCEPTION_CHECK(vm);
|
||||
// ObjectRef::New may return special value if exception occurs.
|
||||
// So we need do special value check before use it.
|
||||
DCHECK_SPECIAL_VALUE(this);
|
||||
JSHandle<JSObject> object(JSNApiHelper::ToJSHandle(this));
|
||||
object->SetNativePointerField(index, nativePointer, callBack, data, nativeBindingsize);
|
||||
object->SetNativePointerField(thread, index, nativePointer, callBack, data, nativeBindingsize);
|
||||
}
|
||||
|
||||
// -------------------------------- NativePointerRef ------------------------------------
|
||||
@ -3975,11 +3977,12 @@ void WeakMapRef::Set(const EcmaVM *vm, const Local<JSValueRef> &key, const Local
|
||||
JSWeakMap::Set(vm->GetJSThread(), weakMap, JSNApiHelper::ToJSHandle(key), JSNApiHelper::ToJSHandle(value));
|
||||
}
|
||||
|
||||
bool WeakMapRef::Has(Local<JSValueRef> key)
|
||||
bool WeakMapRef::Has(const EcmaVM *vm, Local<JSValueRef> key)
|
||||
{
|
||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, false);
|
||||
JSHandle<JSWeakMap> weakMap(JSNApiHelper::ToJSHandle(this));
|
||||
return weakMap->Has(JSNApiHelper::ToJSTaggedValue(*key));
|
||||
return weakMap->Has(thread, JSNApiHelper::ToJSTaggedValue(*key));
|
||||
}
|
||||
|
||||
// ---------------------------------- WeakSetRef --------------------------------------
|
||||
|
@ -5404,7 +5404,7 @@ HWTEST_F_L0(JSNApiSplTest, ObjectRef_SetNativePointerFieldCount)
|
||||
int32_t input = 34; // 34 = random number
|
||||
gettimeofday(&g_beginTime, nullptr);
|
||||
for (int i = 0; i < NUM_COUNT; i++) {
|
||||
object->SetNativePointerFieldCount(input);
|
||||
object->SetNativePointerFieldCount(vm_, input);
|
||||
}
|
||||
gettimeofday(&g_endTime, nullptr);
|
||||
TEST_TIME(ObjectRef::SetNativePointerFieldCount);
|
||||
@ -5416,7 +5416,7 @@ HWTEST_F_L0(JSNApiSplTest, ObjectRef_GetNativePointerFieldCount)
|
||||
CalculateForTime();
|
||||
Local<ObjectRef> object = ObjectRef::New(vm_);
|
||||
int32_t input = 34; // 34 = random number
|
||||
object->SetNativePointerFieldCount(input);
|
||||
object->SetNativePointerFieldCount(vm_, input);
|
||||
gettimeofday(&g_beginTime, nullptr);
|
||||
for (int i = 0; i < NUM_COUNT; i++) {
|
||||
object->GetNativePointerFieldCount();
|
||||
@ -5435,7 +5435,7 @@ HWTEST_F_L0(JSNApiSplTest, ObjectRef_SetNativePointerField)
|
||||
void *vp2 = static_cast<void *>(new std::string("test"));
|
||||
gettimeofday(&g_beginTime, nullptr);
|
||||
for (int i = 0; i < NUM_COUNT; i++) {
|
||||
object->SetNativePointerField(33, vp1, callBack, vp2);
|
||||
object->SetNativePointerField(vm_, 33, vp1, callBack, vp2);
|
||||
}
|
||||
gettimeofday(&g_endTime, nullptr);
|
||||
TEST_TIME(ObjectRef::SetNativePointerField);
|
||||
@ -5449,7 +5449,7 @@ HWTEST_F_L0(JSNApiSplTest, ObjectRef_GetNativePointerField)
|
||||
NativePointerCallback callBack = nullptr;
|
||||
void *vp1 = static_cast<void *>(new std::string("test"));
|
||||
void *vp2 = static_cast<void *>(new std::string("test"));
|
||||
object->SetNativePointerField(33, vp1, callBack, vp2);
|
||||
object->SetNativePointerField(vm_, 33, vp1, callBack, vp2);
|
||||
gettimeofday(&g_beginTime, nullptr);
|
||||
for (int i = 0; i < NUM_COUNT; i++) {
|
||||
object->GetNativePointerField(33);
|
||||
|
@ -1614,14 +1614,14 @@ HWTEST_F_L0(JSNApiTests, ObjectRef_SetNativePointerFieldCount_GetNativePointerFi
|
||||
LocalScope scope(vm_);
|
||||
Local<ObjectRef> object = ObjectRef::New(vm_);
|
||||
int32_t input = 34;
|
||||
object->SetNativePointerFieldCount(input);
|
||||
object->SetNativePointerFieldCount(vm_, input);
|
||||
int32_t res = object->GetNativePointerFieldCount();
|
||||
ASSERT_EQ(res, input);
|
||||
NativePointerCallback callBack = nullptr;
|
||||
void *vp1 = static_cast<void *>(new std::string("test"));
|
||||
void *vp2 = static_cast<void *>(new std::string("test"));
|
||||
std::string *sp1 = static_cast<std::string *>(vp1);
|
||||
object->SetNativePointerField(33, vp1, callBack, vp2);
|
||||
object->SetNativePointerField(vm_, 33, vp1, callBack, vp2);
|
||||
void *res1 = object->GetNativePointerField(33);
|
||||
std::string *sp2 = static_cast<std::string *>(res1);
|
||||
ASSERT_EQ(sp1, sp2);
|
||||
|
@ -731,13 +731,13 @@ void NativePointer(Local<ObjectRef> object, EcmaVM *vm)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "NativePointer";
|
||||
int cnt = 10; // 10 = accommodate quantity
|
||||
object->SetNativePointerFieldCount(cnt);
|
||||
object->SetNativePointerFieldCount(vm, cnt);
|
||||
ASSERT_EQ(cnt, object->GetNativePointerFieldCount());
|
||||
A *a = new A();
|
||||
int cnt2 = 1; // 11 = random Numbers
|
||||
int cnt3 = 11; // 1 = random Numbers
|
||||
object->SetNativePointerField(cnt2, static_cast<void *>(a), nullptr, nullptr);
|
||||
object->SetNativePointerField(cnt3, static_cast<void *>(a), nullptr, nullptr);
|
||||
object->SetNativePointerField(vm, cnt2, static_cast<void *>(a), nullptr, nullptr);
|
||||
object->SetNativePointerField(vm, cnt3, static_cast<void *>(a), nullptr, nullptr);
|
||||
A *value1 = static_cast<A *>(object->GetNativePointerField(cnt2));
|
||||
A *value2 = static_cast<A *>(object->GetNativePointerField(cnt3));
|
||||
if (value1 == nullptr) {
|
||||
@ -2404,9 +2404,9 @@ HWTEST_F_L0(JSNApiSampleTest, sample_demo9_map_test_2_WeakMapref)
|
||||
jsValue2String(vm_, jsVal);
|
||||
}
|
||||
|
||||
bool hasKey2 = weakMap->Has(StringRef::NewFromUtf8(vm_, "key2"));
|
||||
bool hasKey2 = weakMap->Has(vm_, StringRef::NewFromUtf8(vm_, "key2"));
|
||||
GTEST_LOG_(INFO) << "Has Key2 : " << hasKey2;
|
||||
bool hasKey222 = weakMap->Has(StringRef::NewFromUtf8(vm_, "key222"));
|
||||
bool hasKey222 = weakMap->Has(vm_, StringRef::NewFromUtf8(vm_, "key222"));
|
||||
GTEST_LOG_(INFO) << "Has key222 : " << hasKey222;
|
||||
|
||||
GTEST_LOG_(INFO) << "sample_demo9_map_test_2_WeakMapref =======================================";
|
||||
|
@ -186,7 +186,7 @@ JSHandle<JSHClass> ObjectFactory::InitClassClass()
|
||||
{
|
||||
JSHandle<JSHClass> hClassHandle = NewEcmaHClassClass(nullptr, JSHClass::SIZE, JSType::HCLASS);
|
||||
JSHClass *hclass = reinterpret_cast<JSHClass *>(hClassHandle.GetTaggedValue().GetTaggedObject());
|
||||
hclass->SetClass(hclass);
|
||||
hclass->SetClass(thread_, hclass);
|
||||
return hClassHandle;
|
||||
}
|
||||
|
||||
@ -2314,13 +2314,13 @@ JSHandle<JSRealm> ObjectFactory::NewJSRealm()
|
||||
{
|
||||
JSHandle<JSHClass> hClassHandle = NewEcmaHClassClass(nullptr, JSHClass::SIZE, JSType::HCLASS);
|
||||
JSHClass *hclass = reinterpret_cast<JSHClass *>(hClassHandle.GetTaggedValue().GetTaggedObject());
|
||||
hclass->SetClass(hclass);
|
||||
hclass->SetClass(thread_, hclass);
|
||||
JSHandle<JSHClass> realmEnvClass = NewEcmaHClass(*hClassHandle, GlobalEnv::SIZE, JSType::GLOBAL_ENV);
|
||||
JSHandle<GlobalEnv> realmEnvHandle = NewGlobalEnv(*realmEnvClass);
|
||||
|
||||
auto result = TemplateMap::Create(thread_);
|
||||
realmEnvHandle->SetTemplateMap(thread_, result);
|
||||
|
||||
realmEnvHandle->SetJSThread(thread_);
|
||||
Builtins builtins;
|
||||
builtins.Initialize(realmEnvHandle, thread_, false, true);
|
||||
JSHandle<JSTaggedValue> protoValue = thread_->GlobalConstants()->GetHandledJSRealmClass();
|
||||
@ -2409,7 +2409,7 @@ JSHandle<TaggedArray> ObjectFactory::NewAndCopyTaggedArray(JSHandle<TaggedArray>
|
||||
return dstElements;
|
||||
}
|
||||
Region *region = Region::ObjectAddressToRange(reinterpret_cast<TaggedObject *>(*dstElements));
|
||||
if (region->InYoungSpace() && !region->IsMarking()) {
|
||||
if (region->InYoungSpace() && !thread_->IsConcurrentMarkingOrFinished()) {
|
||||
size_t size = oldLength * sizeof(JSTaggedType);
|
||||
if (memcpy_s(reinterpret_cast<void *>(dstElements->GetData()), size,
|
||||
reinterpret_cast<void *>(srcElements->GetData() + k), size) != EOK) {
|
||||
@ -2433,7 +2433,7 @@ JSHandle<TaggedArray> ObjectFactory::NewAndCopyNameDictionary(JSHandle<TaggedArr
|
||||
return dstElements;
|
||||
}
|
||||
Region *region = Region::ObjectAddressToRange(reinterpret_cast<TaggedObject *>(*dstElements));
|
||||
if (region->InYoungSpace() && !region->IsMarking()) {
|
||||
if (region->InYoungSpace() && !thread_->IsConcurrentMarkingOrFinished()) {
|
||||
size_t size = length * sizeof(JSTaggedType);
|
||||
if (memcpy_s(reinterpret_cast<void *>(dstElements->GetData()), size,
|
||||
reinterpret_cast<void *>(srcElements->GetData()), size) != EOK) {
|
||||
@ -2477,7 +2477,7 @@ JSHandle<TaggedArray> ObjectFactory::NewAndCopyTaggedArrayByObject(JSHandle<JSOb
|
||||
return dstElements;
|
||||
}
|
||||
Region *region = Region::ObjectAddressToRange(reinterpret_cast<TaggedObject *>(*dstElements));
|
||||
if (region->InYoungSpace() && !region->IsMarking()) {
|
||||
if (region->InYoungSpace() && !thread_->IsConcurrentMarkingOrFinished()) {
|
||||
size_t size = oldLength * sizeof(JSTaggedType);
|
||||
if (memcpy_s(reinterpret_cast<void *>(dstElements->GetData()), size,
|
||||
reinterpret_cast<void *>(srcElements->GetData() + k), size) != EOK) {
|
||||
@ -2506,7 +2506,7 @@ JSHandle<MutantTaggedArray> ObjectFactory::NewAndCopyMutantTaggedArrayByObject(J
|
||||
return dstElements;
|
||||
}
|
||||
Region *region = Region::ObjectAddressToRange(reinterpret_cast<TaggedObject *>(*dstElements));
|
||||
if (region->InYoungSpace() && !region->IsMarking()) {
|
||||
if (region->InYoungSpace() && !thread_->IsConcurrentMarkingOrFinished()) {
|
||||
size_t size = oldLength * sizeof(JSTaggedType);
|
||||
if (memcpy_s(reinterpret_cast<void *>(dstElements->GetData()), size,
|
||||
reinterpret_cast<void *>(srcElements->GetData() + k), size) != EOK) {
|
||||
|
@ -400,8 +400,8 @@ void BaseDeserializer::UpdateBarrier(uintptr_t addr, ObjectSlot slot)
|
||||
rootRegion->InsertOldToNewRSet(slot.SlotAddress());
|
||||
}
|
||||
|
||||
if (valueRegion->IsMarking()) {
|
||||
Barriers::Update(slot.SlotAddress(), rootRegion, reinterpret_cast<TaggedObject *>(addr), valueRegion);
|
||||
if (thread_->IsConcurrentMarkingOrFinished()) {
|
||||
Barriers::Update(thread_, slot.SlotAddress(), rootRegion, reinterpret_cast<TaggedObject *>(addr), valueRegion);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,10 +319,10 @@ public:
|
||||
EXPECT_EQ(sum, 16); // 16 : test case
|
||||
|
||||
EXPECT_EQ(retSet->GetSize(), 4); // 4 : test case
|
||||
EXPECT_TRUE(retSet->Has(value1.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(value2.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(value3.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(value4.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(thread, value1.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(thread, value2.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(thread, value3.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(thread, value4.GetTaggedValue()));
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
@ -1678,11 +1678,11 @@ void SnapshotProcessor::DeserializeClassWord(TaggedObject *object)
|
||||
auto globalConst = const_cast<GlobalEnvConstants *>(vm_->GetJSThread()->GlobalConstants());
|
||||
JSTaggedValue hclassValue = globalConst->GetGlobalConstantObject(hclassIndex);
|
||||
ASSERT(hclassValue.IsJSHClass());
|
||||
object->SynchronizedSetClass(JSHClass::Cast(hclassValue.GetTaggedObject()));
|
||||
object->SynchronizedSetClass(vm_->GetJSThread(), JSHClass::Cast(hclassValue.GetTaggedObject()));
|
||||
return;
|
||||
}
|
||||
uintptr_t hclassAddr = TaggedObjectEncodeBitToAddr(encodeBit);
|
||||
object->SynchronizedSetClass(reinterpret_cast<JSHClass *>(hclassAddr));
|
||||
object->SynchronizedSetClass(vm_->GetJSThread(), reinterpret_cast<JSHClass *>(hclassAddr));
|
||||
}
|
||||
|
||||
void SnapshotProcessor::DeserializeField(TaggedObject *objectHeader)
|
||||
|
@ -513,7 +513,7 @@ DEF_RUNTIME_STUBS(UpdateHClassForElementsKind)
|
||||
auto targetHClassValue = globalConst->GetGlobalConstantObject(static_cast<size_t>(index));
|
||||
auto hclass = JSHClass::Cast(targetHClassValue.GetTaggedObject());
|
||||
auto array = JSHandle<JSArray>(receiver);
|
||||
array->SynchronizedSetClass(hclass);
|
||||
array->SynchronizedSetClass(thread, hclass);
|
||||
// Update TrackInfo
|
||||
if (!thread->IsPGOProfilerEnable()) {
|
||||
return JSTaggedValue::Hole().GetRawData();
|
||||
@ -2802,15 +2802,16 @@ void RuntimeStubs::MarkingBarrier([[maybe_unused]] uintptr_t argGlue,
|
||||
uintptr_t slotAddr = object + offset;
|
||||
Region *objectRegion = Region::ObjectAddressToRange(object);
|
||||
Region *valueRegion = Region::ObjectAddressToRange(value);
|
||||
auto thread = JSThread::GlueToJSThread(argGlue);
|
||||
#if ECMASCRIPT_ENABLE_BARRIER_CHECK
|
||||
if (!valueRegion->GetJSThread()->GetEcmaVM()->GetHeap()->IsAlive(JSTaggedValue(value).GetHeapObject())) {
|
||||
if (!thread->GetEcmaVM()->GetHeap()->IsAlive(JSTaggedValue(value).GetHeapObject())) {
|
||||
LOG_FULL(FATAL) << "RuntimeStubs::MarkingBarrier checked value:" << value << " is invalid!";
|
||||
}
|
||||
#endif
|
||||
if (!valueRegion->IsMarking()) {
|
||||
if (!thread->IsConcurrentMarkingOrFinished()) {
|
||||
return;
|
||||
}
|
||||
Barriers::Update(slotAddr, objectRegion, value, valueRegion);
|
||||
Barriers::Update(thread, slotAddr, objectRegion, value, valueRegion);
|
||||
}
|
||||
|
||||
void RuntimeStubs::StoreBarrier([[maybe_unused]] uintptr_t argGlue,
|
||||
@ -2819,8 +2820,9 @@ void RuntimeStubs::StoreBarrier([[maybe_unused]] uintptr_t argGlue,
|
||||
uintptr_t slotAddr = object + offset;
|
||||
Region *objectRegion = Region::ObjectAddressToRange(object);
|
||||
Region *valueRegion = Region::ObjectAddressToRange(value);
|
||||
auto thread = JSThread::GlueToJSThread(argGlue);
|
||||
#if ECMASCRIPT_ENABLE_BARRIER_CHECK
|
||||
if (!valueRegion->GetJSThread()->GetEcmaVM()->GetHeap()->IsAlive(JSTaggedValue(value).GetHeapObject())) {
|
||||
if (!thread->GetEcmaVM()->GetHeap()->IsAlive(JSTaggedValue(value).GetHeapObject())) {
|
||||
LOG_FULL(FATAL) << "RuntimeStubs::StoreBarrier checked value:" << value << " is invalid!";
|
||||
}
|
||||
#endif
|
||||
@ -2829,10 +2831,10 @@ void RuntimeStubs::StoreBarrier([[maybe_unused]] uintptr_t argGlue,
|
||||
ASSERT((slotAddr % static_cast<uint8_t>(MemAlignment::MEM_ALIGN_OBJECT)) == 0);
|
||||
objectRegion->InsertOldToNewRSet(slotAddr);
|
||||
}
|
||||
if (!valueRegion->IsMarking()) {
|
||||
if (!thread->IsConcurrentMarkingOrFinished()) {
|
||||
return;
|
||||
}
|
||||
Barriers::Update(slotAddr, objectRegion, value, valueRegion);
|
||||
Barriers::Update(thread, slotAddr, objectRegion, value, valueRegion);
|
||||
}
|
||||
|
||||
bool RuntimeStubs::StringsAreEquals(EcmaString *str1, EcmaString *str2)
|
||||
@ -3173,7 +3175,7 @@ DEF_RUNTIME_STUBS(GetLinkedHash)
|
||||
{
|
||||
RUNTIME_STUBS_HEADER(GetLinkedHash);
|
||||
JSTaggedValue key = GetArg(argv, argc, 0); // 0: means the zeroth parameter
|
||||
return JSTaggedValue(LinkedHash::Hash(key)).GetRawData();
|
||||
return JSTaggedValue(LinkedHash::Hash(thread, key)).GetRawData();
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(LinkedHashMapComputeCapacity)
|
||||
|
@ -174,7 +174,7 @@ void TaggedArray::RemoveElementByIndex(const JSThread *thread, JSHandle<TaggedAr
|
||||
{
|
||||
ASSERT(0 <= index || index < effectiveLength);
|
||||
Region *region = Region::ObjectAddressToRange(reinterpret_cast<TaggedObject *>(*srcArray));
|
||||
if (region->InYoungSpace() && !region->IsMarking()) {
|
||||
if (region->InYoungSpace() && !thread->IsConcurrentMarkingOrFinished()) {
|
||||
size_t taggedTypeSize = JSTaggedValue::TaggedTypeSize();
|
||||
size_t offset = taggedTypeSize * index;
|
||||
auto *addr = reinterpret_cast<JSTaggedType *>(ToUintPtr(srcArray->GetData()) + offset);
|
||||
@ -198,7 +198,7 @@ void TaggedArray::InsertElementByIndex(const JSThread *thread, JSHandle<TaggedAr
|
||||
ASSERT(0 <= index || index <= effectiveLength);
|
||||
ASSERT(effectiveLength < srcArray->GetLength());
|
||||
Region *region = Region::ObjectAddressToRange(reinterpret_cast<TaggedObject *>(*srcArray));
|
||||
if (region->InYoungSpace() && !region->IsMarking()) {
|
||||
if (region->InYoungSpace() && !thread->IsConcurrentMarkingOrFinished()) {
|
||||
size_t taggedTypeSize = JSTaggedValue::TaggedTypeSize();
|
||||
size_t offset = taggedTypeSize * effectiveLength;
|
||||
auto *addr = reinterpret_cast<JSTaggedType *>(ToUintPtr(srcArray->GetData()) + offset);
|
||||
@ -223,7 +223,7 @@ void TaggedArray::CopyTaggedArrayElement(const JSThread *thread, JSHandle<Tagged
|
||||
ASSERT(effectiveLength <= srcElements->GetLength());
|
||||
ASSERT(effectiveLength <= dstElements->GetLength());
|
||||
Region *region = Region::ObjectAddressToRange(reinterpret_cast<TaggedObject *>(*dstElements));
|
||||
if (region->InYoungSpace() && !region->IsMarking()) {
|
||||
if (region->InYoungSpace() && !thread->IsConcurrentMarkingOrFinished()) {
|
||||
size_t size = effectiveLength * sizeof(JSTaggedType);
|
||||
if (memcpy_s(reinterpret_cast<void *>(dstElements->GetData()), size,
|
||||
reinterpret_cast<void *>(srcElements->GetData()), size) != EOK) {
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
static constexpr size_t SIZE = DATA_OFFSET;
|
||||
DECL_VISIT_OBJECT(HASH_OFFSET, SIZE);
|
||||
|
||||
static int Hash(JSTaggedValue key)
|
||||
static int Hash(const JSThread *thread, JSTaggedValue key)
|
||||
{
|
||||
if (key.IsDouble() && key.GetDouble() == 0.0) {
|
||||
key = JSTaggedValue(0);
|
||||
@ -60,9 +60,8 @@ public:
|
||||
int32_t hash = ECMAObject::Cast(key.GetTaggedObject())->GetHash();
|
||||
if (hash == 0) {
|
||||
hash = base::RandomGenerator::GenerateIdentityHash();
|
||||
JSThread *thread = ECMAObject::Cast(key.GetTaggedObject())->GetJSThread();
|
||||
JSHandle<ECMAObject> ecmaObj(thread, key);
|
||||
ECMAObject::Cast(key.GetTaggedObject())->SetHash(hash, ecmaObj);
|
||||
ECMAObject::Cast(key.GetTaggedObject())->SetHash(thread, hash, ecmaObj);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -220,11 +220,11 @@ HWTEST_F_L0(JSAPILightWeightSetTest, IsEmptyHasHasAll)
|
||||
|
||||
tValue = myValue1 + std::to_string(5);
|
||||
value1.Update(factory->NewFromStdString(tValue).GetTaggedValue());
|
||||
result = lws->Has(value1);
|
||||
result = lws->Has(thread, value1);
|
||||
EXPECT_TRUE(result);
|
||||
tValue = myValue1 + std::to_string(NODE_NUMBERS);
|
||||
value1.Update(factory->NewFromStdString(tValue).GetTaggedValue());
|
||||
result = lws->Has(value1);
|
||||
result = lws->Has(thread, value1);
|
||||
EXPECT_FALSE(result);
|
||||
|
||||
std::string myValue2("myvalue");
|
||||
@ -268,7 +268,7 @@ HWTEST_F_L0(JSAPILightWeightSetTest, GetIndexOfRemoveRemoveAtGetValueAt)
|
||||
// test GetIndexOf
|
||||
std::string tValue("myvalue5");
|
||||
value.Update(factory->NewFromStdString(tValue).GetTaggedValue());
|
||||
int32_t index = lws->GetIndexOf(value);
|
||||
int32_t index = lws->GetIndexOf(thread, value);
|
||||
EXPECT_EQ(index, 5); // 5 means the value
|
||||
|
||||
// test GetValueAt
|
||||
@ -326,7 +326,7 @@ HWTEST_F_L0(JSAPILightWeightSetTest, RBTreeGetHashIndex)
|
||||
int32_t size = static_cast<uint32_t>(lws->GetLength());
|
||||
for (uint32_t i = 0; i < NODE_NUMBERS; i++) {
|
||||
value.Update(JSTaggedValue(hashCollisionVector[i]));
|
||||
int32_t index = lws->GetHashIndex(value, size);
|
||||
int32_t index = lws->GetHashIndex(thread, value, size);
|
||||
EXPECT_TRUE(0 <= index && index < size);
|
||||
}
|
||||
}
|
||||
@ -376,18 +376,18 @@ HWTEST_F_L0(JSAPILightWeightSetTest, GetHashAtHasHash)
|
||||
// test GetHashAt
|
||||
int32_t size = static_cast<int32_t>(lws->GetLength());
|
||||
for (uint32_t i = 0; i < NODE_NUMBERS; i++) {
|
||||
hash.Update(JSTaggedValue(lws->Hash(JSTaggedValue(i))));
|
||||
int32_t index = lws->GetHashIndex(hash, size);
|
||||
hash.Update(JSTaggedValue(lws->Hash(thread, JSTaggedValue(i))));
|
||||
int32_t index = lws->GetHashIndex(thread, hash, size);
|
||||
JSTaggedValue getHash= lws->GetHashAt(index);
|
||||
EXPECT_EQ(getHash, hash.GetTaggedValue());
|
||||
}
|
||||
|
||||
// test HasHash
|
||||
for (uint32_t i = 0; i < NODE_NUMBERS; i++) {
|
||||
hash.Update(JSTaggedValue(lws->Hash(JSTaggedValue(i))));
|
||||
hash.Update(JSTaggedValue(lws->Hash(thread, JSTaggedValue(i))));
|
||||
EXPECT_TRUE(lws->HasHash(hash));
|
||||
}
|
||||
hash.Update(JSTaggedValue(lws->Hash(JSTaggedValue(NODE_NUMBERS))));
|
||||
hash.Update(JSTaggedValue(lws->Hash(thread, JSTaggedValue(NODE_NUMBERS))));
|
||||
EXPECT_FALSE(lws->HasHash(hash));
|
||||
}
|
||||
|
||||
|
@ -190,9 +190,9 @@ HWTEST_F_L0(JSMapIteratorTest, Update)
|
||||
// update MapIterator
|
||||
mapIterator->Update(thread);
|
||||
LinkedHashMap *resultMap = LinkedHashMap::Cast(mapIterator->GetIteratedMap().GetTaggedObject());
|
||||
EXPECT_TRUE(resultMap->Has(keyHandle1.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultMap->Has(keyHandle2.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultMap->Has(keyHandle3.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultMap->Has(thread, keyHandle1.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultMap->Has(thread, keyHandle2.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultMap->Has(thread, keyHandle3.GetTaggedValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ HWTEST_F_L0(JSMapTest, AddAndHas)
|
||||
JSHandle<JSTaggedValue> key(factory->NewFromASCII("key"));
|
||||
JSHandle<JSTaggedValue> value(thread, JSTaggedValue(1));
|
||||
JSMap::Set(thread, map, key, value);
|
||||
EXPECT_TRUE(map->Has(key.GetTaggedValue()));
|
||||
EXPECT_TRUE(map->Has(thread, key.GetTaggedValue()));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSMapTest, DeleteAndGet)
|
||||
@ -104,7 +104,7 @@ HWTEST_F_L0(JSMapTest, DeleteAndGet)
|
||||
JSHandle<JSTaggedValue> key(factory->NewFromASCII(keyArray));
|
||||
JSHandle<JSTaggedValue> value(thread, JSTaggedValue(i));
|
||||
JSMap::Set(thread, map, key, value);
|
||||
EXPECT_TRUE(map->Has(key.GetTaggedValue()));
|
||||
EXPECT_TRUE(map->Has(thread, key.GetTaggedValue()));
|
||||
}
|
||||
EXPECT_EQ(map->GetSize(), 40);
|
||||
// whether jsMap has delete key
|
||||
@ -112,7 +112,7 @@ HWTEST_F_L0(JSMapTest, DeleteAndGet)
|
||||
JSHandle<JSTaggedValue> deleteKey(factory->NewFromASCII(keyArray));
|
||||
EXPECT_EQ(map->GetValue(8), JSTaggedValue(8));
|
||||
JSMap::Delete(thread, map, deleteKey);
|
||||
EXPECT_FALSE(map->Has(deleteKey.GetTaggedValue()));
|
||||
EXPECT_FALSE(map->Has(thread, deleteKey.GetTaggedValue()));
|
||||
EXPECT_EQ(map->GetSize(), 39);
|
||||
}
|
||||
|
||||
|
@ -1289,12 +1289,12 @@ HWTEST_F_L0(JSObjectTest, NativePointerField)
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<JSTaggedValue> objFunc(thread, JSObjectTestCreate(thread));
|
||||
JSHandle<JSObject> obj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFunc), objFunc);
|
||||
ECMAObject::SetHash(87, JSHandle<ECMAObject>::Cast(obj));
|
||||
ECMAObject::SetHash(thread, 87, JSHandle<ECMAObject>::Cast(obj));
|
||||
EXPECT_TRUE(obj->GetHash() == 87);
|
||||
|
||||
obj->SetNativePointerFieldCount(1);
|
||||
obj->SetNativePointerFieldCount(thread, 1);
|
||||
char array[] = "Hello World!";
|
||||
obj->SetNativePointerField(0, array, nullptr, nullptr);
|
||||
obj->SetNativePointerField(thread, 0, array, nullptr, nullptr);
|
||||
int32_t count = obj->GetNativePointerFieldCount();
|
||||
EXPECT_TRUE(count == 1);
|
||||
void *pointer = obj->GetNativePointerField(0);
|
||||
|
@ -315,10 +315,10 @@ public:
|
||||
EXPECT_EQ(sum, 16); // 16 : test case
|
||||
|
||||
EXPECT_EQ(retSet->GetSize(), 4); // 4 : test case
|
||||
EXPECT_TRUE(retSet->Has(value1.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(value2.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(value3.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(value4.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(thread, value1.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(thread, value2.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(thread, value3.GetTaggedValue()));
|
||||
EXPECT_TRUE(retSet->Has(thread, value4.GetTaggedValue()));
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
@ -125,9 +125,9 @@ HWTEST_F_L0(JSSetIteratorTest, Update)
|
||||
// update SetIterator
|
||||
setIterator->Update(thread);
|
||||
LinkedHashSet *resultSet = LinkedHashSet::Cast(setIterator->GetIteratedSet().GetTaggedObject());
|
||||
EXPECT_TRUE(resultSet->Has(keyHandle1.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultSet->Has(keyHandle2.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultSet->Has(keyHandle3.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultSet->Has(thread, keyHandle1.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultSet->Has(thread, keyHandle2.GetTaggedValue()));
|
||||
EXPECT_TRUE(resultSet->Has(thread, keyHandle3.GetTaggedValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ HWTEST_F_L0(JSSetTest, AddAndHas)
|
||||
|
||||
JSHandle<JSTaggedValue> key(factory->NewFromASCII("key"));
|
||||
JSSet::Add(thread, set, key);
|
||||
EXPECT_TRUE(set->Has(key.GetTaggedValue()));
|
||||
EXPECT_TRUE(set->Has(thread, key.GetTaggedValue()));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSSetTest, DeleteAndGet)
|
||||
@ -103,14 +103,14 @@ HWTEST_F_L0(JSSetTest, DeleteAndGet)
|
||||
keyArray[3] = '1' + i;
|
||||
JSHandle<JSTaggedValue> key(factory->NewFromASCII(keyArray));
|
||||
JSSet::Add(thread, set, key);
|
||||
EXPECT_TRUE(set->Has(key.GetTaggedValue()));
|
||||
EXPECT_TRUE(set->Has(thread, key.GetTaggedValue()));
|
||||
}
|
||||
EXPECT_EQ(set->GetSize(), 40);
|
||||
// whether jsSet has delete key
|
||||
keyArray[3] = '1' + 8;
|
||||
JSHandle<JSTaggedValue> deleteKey(factory->NewFromASCII(keyArray));
|
||||
JSSet::Delete(thread, set, deleteKey);
|
||||
EXPECT_FALSE(set->Has(deleteKey.GetTaggedValue()));
|
||||
EXPECT_FALSE(set->Has(thread, deleteKey.GetTaggedValue()));
|
||||
EXPECT_EQ(set->GetSize(), 39);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ HWTEST_F_L0(LinkedHashTableTest, addKeyAndValue)
|
||||
EXPECT_EQ(dictHandle->NumberOfElements(), 1);
|
||||
|
||||
// test find()
|
||||
int entry1 = dictHandle->FindElement(key1.GetTaggedValue());
|
||||
int entry1 = dictHandle->FindElement(thread, key1.GetTaggedValue());
|
||||
EXPECT_EQ(key1.GetTaggedValue(), dictHandle->GetKey(entry1));
|
||||
EXPECT_EQ(value1.GetTaggedValue(), dictHandle->GetValue(entry1));
|
||||
|
||||
@ -108,12 +108,12 @@ HWTEST_F_L0(LinkedHashTableTest, addKeyAndValue)
|
||||
EXPECT_EQ(dictHandle->NumberOfElements(), 2);
|
||||
// test remove()
|
||||
dictHandle = LinkedHashMap::Delete(thread, dictHandle, key1);
|
||||
EXPECT_EQ(-1, dictHandle->FindElement(key1.GetTaggedValue()));
|
||||
EXPECT_EQ(-1, dictHandle->FindElement(thread, key1.GetTaggedValue()));
|
||||
EXPECT_EQ(dictHandle->NumberOfElements(), 1);
|
||||
|
||||
JSHandle<JSTaggedValue> undefinedKey(thread, JSTaggedValue::Undefined());
|
||||
dictHandle = LinkedHashMap::Set(thread, dictHandle, undefinedKey, value1);
|
||||
int entry2 = dictHandle->FindElement(undefinedKey.GetTaggedValue());
|
||||
int entry2 = dictHandle->FindElement(thread, undefinedKey.GetTaggedValue());
|
||||
EXPECT_EQ(value1.GetTaggedValue(), dictHandle->GetValue(entry2));
|
||||
}
|
||||
|
||||
@ -141,18 +141,18 @@ HWTEST_F_L0(LinkedHashTableTest, SetaddKeyAndValue)
|
||||
EXPECT_EQ(setHandle->NumberOfElements(), 1);
|
||||
|
||||
// test has()
|
||||
EXPECT_TRUE(setHandle->Has(key1.GetTaggedValue()));
|
||||
EXPECT_TRUE(setHandle->Has(thread, key1.GetTaggedValue()));
|
||||
|
||||
setHandle = LinkedHashSet::Add(thread, setHandle, key2);
|
||||
EXPECT_EQ(setHandle->NumberOfElements(), 2);
|
||||
// test remove()
|
||||
setHandle = LinkedHashSet::Delete(thread, setHandle, key1);
|
||||
EXPECT_EQ(-1, setHandle->FindElement(key1.GetTaggedValue()));
|
||||
EXPECT_EQ(-1, setHandle->FindElement(thread, key1.GetTaggedValue()));
|
||||
EXPECT_EQ(setHandle->NumberOfElements(), 1);
|
||||
|
||||
JSHandle<JSTaggedValue> undefinedKey(thread, JSTaggedValue::Undefined());
|
||||
setHandle = LinkedHashSet::Add(thread, setHandle, undefinedKey);
|
||||
EXPECT_TRUE(setHandle->Has(undefinedKey.GetTaggedValue()));
|
||||
EXPECT_TRUE(setHandle->Has(thread, undefinedKey.GetTaggedValue()));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(LinkedHashTableTest, GrowCapacity)
|
||||
@ -171,7 +171,7 @@ HWTEST_F_L0(LinkedHashTableTest, GrowCapacity)
|
||||
|
||||
// test insert()
|
||||
dictHandle = LinkedHashMap::Set(thread, dictHandle, key, value);
|
||||
EXPECT_EQ(i, dictHandle->FindElement(key.GetTaggedValue()));
|
||||
EXPECT_EQ(i, dictHandle->FindElement(thread, key.GetTaggedValue()));
|
||||
}
|
||||
|
||||
// test order
|
||||
@ -180,7 +180,7 @@ HWTEST_F_L0(LinkedHashTableTest, GrowCapacity)
|
||||
keyArray[6] = 0;
|
||||
JSHandle<EcmaString> stringKey = factory->NewFromASCII(keyArray);
|
||||
// test insert()
|
||||
EXPECT_EQ(i, dictHandle->FindElement(stringKey.GetTaggedValue()));
|
||||
EXPECT_EQ(i, dictHandle->FindElement(thread, stringKey.GetTaggedValue()));
|
||||
}
|
||||
EXPECT_EQ(dictHandle->NumberOfElements(), 33);
|
||||
EXPECT_EQ(dictHandle->Capacity(), 64);
|
||||
@ -203,7 +203,7 @@ HWTEST_F_L0(LinkedHashTableTest, SetGrowCapacity)
|
||||
|
||||
// test insert()
|
||||
setHandle = LinkedHashSet::Add(thread, setHandle, key);
|
||||
EXPECT_EQ(i, setHandle->FindElement(key.GetTaggedValue()));
|
||||
EXPECT_EQ(i, setHandle->FindElement(thread, key.GetTaggedValue()));
|
||||
}
|
||||
|
||||
// test order
|
||||
@ -212,7 +212,7 @@ HWTEST_F_L0(LinkedHashTableTest, SetGrowCapacity)
|
||||
keyArray[6] = 0;
|
||||
JSHandle<EcmaString> stringKey = factory->NewFromASCII(keyArray);
|
||||
// test insert()
|
||||
EXPECT_EQ(i, setHandle->FindElement(stringKey.GetTaggedValue()));
|
||||
EXPECT_EQ(i, setHandle->FindElement(thread, stringKey.GetTaggedValue()));
|
||||
}
|
||||
EXPECT_EQ(setHandle->NumberOfElements(), 33);
|
||||
EXPECT_EQ(setHandle->Capacity(), 64);
|
||||
@ -244,7 +244,7 @@ HWTEST_F_L0(LinkedHashTableTest, ShrinkCapacity)
|
||||
keyArray[6] = 0;
|
||||
JSHandle<EcmaString> stringKey = factory->NewFromASCII(keyArray);
|
||||
// test insert()
|
||||
EXPECT_EQ(i, dictHandle->FindElement(stringKey.GetTaggedValue()));
|
||||
EXPECT_EQ(i, dictHandle->FindElement(thread, stringKey.GetTaggedValue()));
|
||||
}
|
||||
EXPECT_EQ(dictHandle->NumberOfElements(), 9);
|
||||
EXPECT_EQ(dictHandle->Capacity(), 16);
|
||||
@ -276,7 +276,7 @@ HWTEST_F_L0(LinkedHashTableTest, SetShrinkCapacity)
|
||||
keyArray[6] = 0;
|
||||
JSHandle<EcmaString> stringKey = factory->NewFromASCII(keyArray);
|
||||
// test insert()
|
||||
EXPECT_EQ(i, setHandle->FindElement(stringKey.GetTaggedValue()));
|
||||
EXPECT_EQ(i, setHandle->FindElement(thread, stringKey.GetTaggedValue()));
|
||||
}
|
||||
EXPECT_EQ(setHandle->NumberOfElements(), 9);
|
||||
EXPECT_EQ(setHandle->Capacity(), 16);
|
||||
|
@ -72,7 +72,7 @@ protected:
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
key.Update(factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
value.Update(factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(key.GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, key.GetTaggedValue());
|
||||
head = factory->NewLinkedNode(hash, key, value, head);
|
||||
}
|
||||
return head;
|
||||
@ -86,7 +86,7 @@ HWTEST_F_L0(LinkedNodeTest, LinkedNodeCreate)
|
||||
std::string v("testValue");
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(k).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> value(thread, factory->NewFromStdString(v).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(factory->NewFromStdString(k).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, factory->NewFromStdString(k).GetTaggedValue());
|
||||
JSHandle<LinkedNode> hole(thread, JSTaggedValue::Hole());
|
||||
JSHandle<LinkedNode> newNode = factory->NewLinkedNode(hash, key, value, hole);
|
||||
EXPECT_TRUE(!newNode.GetTaggedValue().IsHole());
|
||||
|
@ -68,7 +68,7 @@ HWTEST_F_L0(RBTreeNodeTest, RBTreeNodeCreate)
|
||||
std::string v("testValue");
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(k).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> value(thread, factory->NewFromStdString(v).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(factory->NewFromStdString(k).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, factory->NewFromStdString(k).GetTaggedValue());
|
||||
JSHandle<RBTreeNode> newNode = factory->NewTreeNode(hash, key, value);
|
||||
|
||||
EXPECT_TRUE(!newNode.GetTaggedValue().IsHole());
|
||||
@ -87,7 +87,7 @@ HWTEST_F_L0(RBTreeNodeTest, RBTreeNodeSetAndGet)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> value(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
rootNode = RBTreeNode::Set(thread, rootNode, hash, key, value);
|
||||
rootNode->SetIsRed(thread, JSTaggedValue(false));
|
||||
}
|
||||
@ -98,7 +98,7 @@ HWTEST_F_L0(RBTreeNodeTest, RBTreeNodeSetAndGet)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> value(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(key.GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, key.GetTaggedValue());
|
||||
// test get
|
||||
JSHandle<JSTaggedValue> rootNodeVa(thread, rootNode.GetTaggedValue());
|
||||
JSTaggedValue gValue = RBTreeNode::GetTreeNode(thread, rootNodeVa, hash, key);
|
||||
@ -119,7 +119,7 @@ HWTEST_F_L0(RBTreeNodeTest, RBTreeNodeDelete)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> value(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
rootNode = RBTreeNode::Set(thread, rootNode, hash, key, value);
|
||||
rootNode->SetIsRed(thread, JSTaggedValue(false));
|
||||
}
|
||||
@ -128,7 +128,7 @@ HWTEST_F_L0(RBTreeNodeTest, RBTreeNodeDelete)
|
||||
for (uint32_t i = 0; i < NODE_NUMBERS / 2; i++) {
|
||||
std::string iKey = myKey + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(key.GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, key.GetTaggedValue());
|
||||
JSTaggedValue holeValue = JSTaggedValue::Hole();
|
||||
JSTaggedValue dValue =
|
||||
RBTreeNode::Delete(thread, rootNode.GetTaggedValue(), hash, key.GetTaggedValue(), holeValue);
|
||||
@ -139,7 +139,7 @@ HWTEST_F_L0(RBTreeNodeTest, RBTreeNodeDelete)
|
||||
for (uint32_t i = 0; i < NODE_NUMBERS / 2; i++) {
|
||||
std::string iKey = myKey + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(key.GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, key.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> rootNodeVa(thread, rootNode.GetTaggedValue());
|
||||
JSTaggedValue gValue = RBTreeNode::GetTreeNode(thread, rootNodeVa, hash, key);
|
||||
EXPECT_EQ(gValue, JSTaggedValue::Hole());
|
||||
@ -150,7 +150,7 @@ HWTEST_F_L0(RBTreeNodeTest, RBTreeNodeDelete)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> value(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(key.GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, key.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> rootNodeVa(thread, rootNode.GetTaggedValue());
|
||||
JSTaggedValue gValue = RBTreeNode::GetTreeNode(thread, rootNodeVa, hash, key);
|
||||
JSTaggedValue resValue = RBTreeNode::Cast(gValue.GetTaggedObject())->GetValue();
|
||||
@ -169,7 +169,7 @@ HWTEST_F_L0(RBTreeNodeTest, RBTreeNodeDivide)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> value(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
rootNode = RBTreeNode::Set(thread, rootNode, hash, key, value);
|
||||
rootNode->SetIsRed(thread, JSTaggedValue(false));
|
||||
}
|
||||
@ -220,7 +220,7 @@ HWTEST_F_L0(RBTreeNodeTest, RBTreeNodeUntreeify)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> key(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> value(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
int hash = TaggedNode::Hash(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
rootNode = RBTreeNode::Set(thread, rootNode, hash, key, value);
|
||||
rootNode->SetIsRed(thread, JSTaggedValue(false));
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ HWTEST_F_L0(TaggedHashArrayTest, NewLinkedNode)
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<JSTaggedValue> hashKey(factory->NewFromASCII("key"));
|
||||
JSHandle<JSTaggedValue> hashKeyValue(thread, JSTaggedValue(11)); // 11: key value
|
||||
int keyHash = TaggedNode::Hash(hashKey.GetTaggedValue());
|
||||
int keyHash = TaggedNode::Hash(thread, hashKey.GetTaggedValue());
|
||||
JSHandle<LinkedNode> linkedNode =
|
||||
TaggedHashArray::NewLinkedNode(thread, keyHash, hashKey, hashKeyValue);
|
||||
EXPECT_TRUE(*linkedNode != nullptr);
|
||||
@ -99,7 +99,7 @@ HWTEST_F_L0(TaggedHashArrayTest, NewTreeNode)
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<JSTaggedValue> hashKey(factory->NewFromASCII("key"));
|
||||
JSHandle<JSTaggedValue> hashKeyValue(thread, JSTaggedValue(12)); // 12: key value
|
||||
int keyHash = TaggedNode::Hash(hashKey.GetTaggedValue());
|
||||
int keyHash = TaggedNode::Hash(thread, hashKey.GetTaggedValue());
|
||||
JSHandle<RBTreeNode> treeNode =
|
||||
TaggedHashArray::NewTreeNode(thread, keyHash, hashKey, hashKeyValue);
|
||||
EXPECT_TRUE(*treeNode != nullptr);
|
||||
@ -136,10 +136,10 @@ HWTEST_F_L0(TaggedHashArrayTest, SetValAndGetLinkNode)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> listKey(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> listValue(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(listKey.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, listKey.GetTaggedValue());
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, listKey, listValue);
|
||||
}
|
||||
keyHash = TaggedNode::Hash(myKey4.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey4.GetTaggedValue());
|
||||
// change value and add new key
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, myKey4, myKey4Value);
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, myKey8, myKey8Value);
|
||||
@ -180,13 +180,13 @@ HWTEST_F_L0(TaggedHashArrayTest, SetValAndGetTreeNode)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> treeKey(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> treeValue(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(treeKey.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, treeKey.GetTaggedValue());
|
||||
JSHandle<RBTreeNode> rootTreeWithValueNode =
|
||||
RBTreeNode::Set(thread, rootTreeNode, keyHash, treeKey, treeValue);
|
||||
uint32_t hashArrayIndex = static_cast<uint32_t>(numOfElement - 1) & keyHash;
|
||||
taggedHashArray->Set(thread, hashArrayIndex, rootTreeWithValueNode.GetTaggedValue());
|
||||
}
|
||||
keyHash = TaggedNode::Hash(myKey5.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey5.GetTaggedValue());
|
||||
// change value and add new key
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, myKey5, myKey5Value);
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, myKey8, myKey8Value);
|
||||
@ -226,19 +226,19 @@ HWTEST_F_L0(TaggedHashArrayTest, RemoveLinkNode)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> listKey(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> listValue(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(listKey.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, listKey.GetTaggedValue());
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, listKey, listValue);
|
||||
}
|
||||
keyHash = TaggedNode::Hash(myKey5.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey5.GetTaggedValue());
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, myKey8, myKey8Value);
|
||||
|
||||
// test Remove()
|
||||
keyHash = TaggedNode::Hash(myKey4.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey4.GetTaggedValue());
|
||||
JSTaggedValue currentNodeVal =taggedHashArray->RemoveNode(thread, keyHash, myKey4.GetTaggedValue());
|
||||
EXPECT_EQ(currentNodeVal, myKey4Value.GetTaggedValue());
|
||||
|
||||
// test Remove() with linkNode has next value
|
||||
keyHash = TaggedNode::Hash(myKey5.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey5.GetTaggedValue());
|
||||
currentNodeVal = taggedHashArray->RemoveNode(thread, keyHash, myKey8.GetTaggedValue());
|
||||
EXPECT_EQ(currentNodeVal, myKey8Value.GetTaggedValue());
|
||||
}
|
||||
@ -269,13 +269,13 @@ HWTEST_F_L0(TaggedHashArrayTest, RemoveTreeNode)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> treeKey(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> treeValue(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(treeKey.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, treeKey.GetTaggedValue());
|
||||
JSHandle<RBTreeNode> rootTreeWithValueNode =
|
||||
RBTreeNode::Set(thread, rootTreeNode, keyHash, treeKey, treeValue);
|
||||
uint32_t hashArrayIndex = static_cast<uint32_t>(numOfElement - 1) & keyHash;
|
||||
taggedHashArray->Set(thread, hashArrayIndex, rootTreeWithValueNode.GetTaggedValue());
|
||||
}
|
||||
keyHash = TaggedNode::Hash(myKey5.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey5.GetTaggedValue());
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, myKey8, myKey8Value);
|
||||
uint32_t keyHashIndex = static_cast<uint32_t>(numOfElement - 1) & keyHash;
|
||||
JSHandle<RBTreeNode> hashTreeNode(thread, taggedHashArray->Get(keyHashIndex));
|
||||
@ -315,25 +315,25 @@ HWTEST_F_L0(TaggedHashArrayTest, ResetLinkNodeSize)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> listKey(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> listValue(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(listKey.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, listKey.GetTaggedValue());
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, listKey, listValue);
|
||||
}
|
||||
keyHash = TaggedNode::Hash(myKey5.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey5.GetTaggedValue());
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, myKey8, myKey8Value);
|
||||
// remove node
|
||||
taggedHashArray->RemoveNode(thread, keyHash, myKey5.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(myKey4.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey4.GetTaggedValue());
|
||||
taggedHashArray->RemoveNode(thread, keyHash, myKey4.GetTaggedValue());
|
||||
|
||||
// test Resize()
|
||||
taggedHashArray = TaggedHashArray::Resize(thread, taggedHashArray, numOfElement);
|
||||
EXPECT_EQ(taggedHashArray->GetLength(), 16U); // 16: reseted length
|
||||
|
||||
keyHash = TaggedNode::Hash(myKey4.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey4.GetTaggedValue());
|
||||
uint32_t hashArrayIndex = static_cast<uint32_t>(numOfElement - 1) & keyHash;
|
||||
EXPECT_TRUE(taggedHashArray->Get(hashArrayIndex).IsHole());
|
||||
|
||||
keyHash = TaggedNode::Hash(myKey5.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey5.GetTaggedValue());
|
||||
hashArrayIndex = static_cast<uint32_t>(numOfElement - 1) & keyHash;
|
||||
JSHandle<LinkedNode> hashNode(thread, taggedHashArray->Get(hashArrayIndex));
|
||||
EXPECT_EQ(hashNode->GetValue(), myKey8Value.GetTaggedValue());
|
||||
@ -367,13 +367,13 @@ HWTEST_F_L0(TaggedHashArrayTest, GetCurrentNode)
|
||||
std::string iValue = myValue + std::to_string(i);
|
||||
JSHandle<JSTaggedValue> treeKey(thread, factory->NewFromStdString(iKey).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> treeValue(thread, factory->NewFromStdString(iValue).GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(treeKey.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, treeKey.GetTaggedValue());
|
||||
JSHandle<RBTreeNode> rootTreeWithValueNode =
|
||||
RBTreeNode::Set(thread, rootTreeNode, keyHash, treeKey, treeValue);
|
||||
uint32_t hashArrayIndex = static_cast<uint32_t>(numOfElement - 1) & keyHash;
|
||||
taggedHashArray->Set(thread, hashArrayIndex, rootTreeWithValueNode.GetTaggedValue());
|
||||
}
|
||||
keyHash = TaggedNode::Hash(myKey5.GetTaggedValue());
|
||||
keyHash = TaggedNode::Hash(thread, myKey5.GetTaggedValue());
|
||||
TaggedHashArray::SetVal(thread, taggedHashArray, keyHash, myKey8, myKey8Value);
|
||||
// test GetCurrentNode()
|
||||
uint32_t nodeIndex = static_cast<uint32_t>(numOfElement - 1) & keyHash;
|
||||
|
@ -50,7 +50,7 @@ void ObjectGetAllPropertyNamesFuzzTest(const uint8_t *data, size_t size)
|
||||
}
|
||||
Local<ObjectRef> object = ObjectRef::New(vm);
|
||||
NativePointerCallback callBack = nullptr;
|
||||
object->SetNativePointerField(index, (void *)data, callBack, (void *)data);
|
||||
object->SetNativePointerField(vm, index, (void *)data, callBack, (void *)data);
|
||||
object->GetAllPropertyNames(vm, filter);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
@ -77,7 +77,7 @@ void ObjectGetNativePointerFieldCountFuzzTest(const uint8_t *data, size_t size)
|
||||
key = 1024; // 1024 : 1M in size
|
||||
}
|
||||
Local<ObjectRef> object = ObjectRef::New(vm);
|
||||
object->SetNativePointerFieldCount(key);
|
||||
object->SetNativePointerFieldCount(vm, key);
|
||||
object->GetNativePointerFieldCount();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
@ -102,7 +102,7 @@ void ObjectGetOwnEnumerablePropertyNamesFuzzTest(const uint8_t *data, size_t siz
|
||||
}
|
||||
Local<ObjectRef> object = ObjectRef::New(vm);
|
||||
NativePointerCallback callBack = nullptr;
|
||||
object->SetNativePointerField(index, (void *)data, callBack, (void *)data);
|
||||
object->SetNativePointerField(vm, index, (void *)data, callBack, (void *)data);
|
||||
object->GetOwnEnumerablePropertyNames(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
@ -127,7 +127,7 @@ void ObjectGetOwnPropertyNamesFuzzTest(const uint8_t *data, size_t size)
|
||||
}
|
||||
Local<ObjectRef> object = ObjectRef::New(vm);
|
||||
NativePointerCallback callBack = nullptr;
|
||||
object->SetNativePointerField(index, (void *)data, callBack, (void *)data);
|
||||
object->SetNativePointerField(vm, index, (void *)data, callBack, (void *)data);
|
||||
object->GetOwnPropertyNames(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace OHOS {
|
||||
}
|
||||
Local<ObjectRef> object = ObjectRef::New(vm);
|
||||
NativePointerCallback callBack = nullptr;
|
||||
object->SetNativePointerField(index, (void *)data, callBack, (void *)data);
|
||||
object->SetNativePointerField(vm, index, (void *)data, callBack, (void *)data);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace OHOS {
|
||||
key = 1024; // 1024 : 1M in size
|
||||
}
|
||||
Local<ObjectRef> object = ObjectRef::New(vm);
|
||||
object->SetNativePointerFieldCount(key);
|
||||
object->SetNativePointerFieldCount(vm, key);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user