mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
fix container using error and gc bug
Signed-off-by: wengchangcheng <wengchangcheng@huawei.com>
This commit is contained in:
parent
3e552f1be0
commit
9a7fcb6e3c
@ -414,7 +414,7 @@ JSTaggedValue BuiltinsPromise::PerformPromiseThen(JSThread *thread, const JSHand
|
||||
argv->Set(thread, 1, promise->GetPromiseResult());
|
||||
|
||||
JSHandle<JSFunction> promiseReactionsJob(env->GetPromiseReactionJob());
|
||||
job->EnqueueJob(thread, job::QueueType::QUEUE_PROMISE, promiseReactionsJob, argv);
|
||||
job::MicroJobQueue::EnqueueJob(thread, job, job::QueueType::QUEUE_PROMISE, promiseReactionsJob, argv);
|
||||
} else if (JSTaggedValue::SameValue(promise->GetPromiseState(),
|
||||
JSTaggedValue(static_cast<int32_t>(PromiseStatus::REJECTED)))) {
|
||||
JSHandle<TaggedArray> argv = factory->NewTaggedArray(2); // 2: 2 means two args stored in array
|
||||
@ -422,7 +422,7 @@ JSTaggedValue BuiltinsPromise::PerformPromiseThen(JSThread *thread, const JSHand
|
||||
argv->Set(thread, 1, promise->GetPromiseResult());
|
||||
|
||||
JSHandle<JSFunction> promiseReactionsJob(env->GetPromiseReactionJob());
|
||||
job->EnqueueJob(thread, job::QueueType::QUEUE_PROMISE, promiseReactionsJob, argv);
|
||||
job::MicroJobQueue::EnqueueJob(thread, job, job::QueueType::QUEUE_PROMISE, promiseReactionsJob, argv);
|
||||
}
|
||||
return capability->GetPromise();
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ JSTaggedValue BuiltinsPromiseHandler::Resolve(EcmaRuntimeCallInfo *argv)
|
||||
|
||||
JSHandle<JSFunction> promiseResolveThenableJob(env->GetPromiseResolveThenableJob());
|
||||
JSHandle<job::MicroJobQueue> job = thread->GetEcmaVM()->GetMicroJobQueue();
|
||||
job->EnqueueJob(thread, job::QueueType::QUEUE_PROMISE, promiseResolveThenableJob, arguments);
|
||||
job::MicroJobQueue::EnqueueJob(thread, job, job::QueueType::QUEUE_PROMISE, promiseResolveThenableJob, arguments);
|
||||
|
||||
// 13. Return undefined.
|
||||
return JSTaggedValue::Undefined();
|
||||
|
@ -449,7 +449,7 @@ HWTEST_F_L0(BuiltinsPromiseTest, Race2)
|
||||
*/
|
||||
auto microJobQueue = EcmaVM::Cast(instance)->GetMicroJobQueue();
|
||||
if (!thread->HasPendingException()) {
|
||||
microJobQueue->ExecutePendingJob(thread);
|
||||
job::MicroJobQueue::ExecutePendingJob(thread, microJobQueue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ HWTEST_F_L0(BuiltinsPromiseTest, All)
|
||||
*/
|
||||
auto microJobQueue = EcmaVM::Cast(instance)->GetMicroJobQueue();
|
||||
if (!thread->HasPendingException()) {
|
||||
microJobQueue->ExecutePendingJob(thread);
|
||||
job::MicroJobQueue::ExecutePendingJob(thread, microJobQueue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -606,7 +606,7 @@ HWTEST_F_L0(BuiltinsPromiseTest, Catch)
|
||||
*/
|
||||
auto microJobQueue = EcmaVM::Cast(instance)->GetMicroJobQueue();
|
||||
if (!thread->HasPendingException()) {
|
||||
microJobQueue->ExecutePendingJob(thread);
|
||||
job::MicroJobQueue::ExecutePendingJob(thread, microJobQueue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -664,7 +664,7 @@ HWTEST_F_L0(BuiltinsPromiseTest, ThenResolve)
|
||||
*/
|
||||
auto microJobQueue = EcmaVM::Cast(instance)->GetMicroJobQueue();
|
||||
if (!thread->HasPendingException()) {
|
||||
microJobQueue->ExecutePendingJob(thread);
|
||||
job::MicroJobQueue::ExecutePendingJob(thread, microJobQueue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -721,7 +721,7 @@ HWTEST_F_L0(BuiltinsPromiseTest, ThenReject)
|
||||
*/
|
||||
auto microJobQueue = EcmaVM::Cast(instance)->GetMicroJobQueue();
|
||||
if (!thread->HasPendingException()) {
|
||||
microJobQueue->ExecutePendingJob(thread);
|
||||
job::MicroJobQueue::ExecutePendingJob(thread, microJobQueue);
|
||||
}
|
||||
}
|
||||
} // namespace panda::test
|
||||
|
@ -42,12 +42,13 @@ void EcmaModule::AddItem(const JSThread *thread, JSHandle<EcmaModule> module, JS
|
||||
JSHandle<JSTaggedValue> data(thread, module->GetNameDictionary());
|
||||
if (data->IsUndefined()) {
|
||||
JSHandle<NameDictionary> dict(thread, NameDictionary::Create(thread, DICTIONART_CAP));
|
||||
auto result = dict->Put(thread, dict, itemName, itemValue, PropertyAttributes::Default());
|
||||
module->SetNameDictionary(thread, JSTaggedValue(result));
|
||||
NameDictionary *newDict = NameDictionary::Put(thread, dict, itemName, itemValue, PropertyAttributes::Default());
|
||||
module->SetNameDictionary(thread, JSTaggedValue(newDict));
|
||||
} else {
|
||||
JSHandle<NameDictionary> dataDict = JSHandle<NameDictionary>::Cast(data);
|
||||
auto result = dataDict->Put(thread, dataDict, itemName, itemValue, PropertyAttributes::Default());
|
||||
module->SetNameDictionary(thread, JSTaggedValue(result));
|
||||
NameDictionary *newDict =
|
||||
NameDictionary::Put(thread, dataDict, itemName, itemValue, PropertyAttributes::Default());
|
||||
module->SetNameDictionary(thread, JSTaggedValue(newDict));
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,20 +118,21 @@ ModuleManager::ModuleManager(EcmaVM *vm) : vm_(vm)
|
||||
// class ModuleManager
|
||||
void ModuleManager::AddModule(JSHandle<JSTaggedValue> moduleName, JSHandle<JSTaggedValue> module)
|
||||
{
|
||||
[[maybe_unused]] EcmaHandleScope scope(vm_->GetJSThread());
|
||||
JSHandle<NameDictionary> dict(vm_->GetJSThread(), ecmaModules_);
|
||||
JSThread *thread = vm_->GetJSThread();
|
||||
[[maybe_unused]] EcmaHandleScope scope(thread);
|
||||
JSHandle<NameDictionary> dict(thread, ecmaModules_);
|
||||
ecmaModules_ =
|
||||
JSTaggedValue(dict->Put(vm_->GetJSThread(), dict, moduleName, module, PropertyAttributes::Default()));
|
||||
JSTaggedValue(NameDictionary::Put(thread, dict, moduleName, module, PropertyAttributes::Default()));
|
||||
}
|
||||
|
||||
void ModuleManager::RemoveModule(JSHandle<JSTaggedValue> moduleName)
|
||||
{
|
||||
[[maybe_unused]] EcmaHandleScope scope(vm_->GetJSThread());
|
||||
JSThread *thread = vm_->GetJSThread();
|
||||
[[maybe_unused]] EcmaHandleScope scope(thread);
|
||||
JSHandle<NameDictionary> moduleItems(thread, ecmaModules_);
|
||||
int entry = moduleItems->FindEntry(moduleName.GetTaggedValue());
|
||||
if (entry != -1) {
|
||||
NameDictionary::Remove(vm_->GetJSThread(), moduleItems, entry); // discard return
|
||||
ecmaModules_ = JSTaggedValue(NameDictionary::Remove(thread, moduleItems, entry));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,7 @@ Expected<int, Runtime::Error> EcmaVM::InvokeEcmaEntrypoint(const panda_file::Fil
|
||||
params->MakeArgList(*jsargs);
|
||||
panda::ecmascript::InvokeJsFunction(thread_, func, global, newTarget, params);
|
||||
if (!thread_->HasPendingException()) {
|
||||
job::MicroJobQueue::Cast(microJobQueue_.GetTaggedObject())->ExecutePendingJob(thread_);
|
||||
job::MicroJobQueue::ExecutePendingJob(thread_, GetMicroJobQueue());
|
||||
}
|
||||
|
||||
// print exception information
|
||||
@ -650,7 +650,7 @@ void EcmaVM::ClearBufferData()
|
||||
bool EcmaVM::ExecutePromisePendingJob() const
|
||||
{
|
||||
if (!thread_->HasPendingException()) {
|
||||
job::MicroJobQueue::Cast(microJobQueue_.GetTaggedObject())->ExecutePendingJob(thread_);
|
||||
job::MicroJobQueue::ExecutePendingJob(thread_, GetMicroJobQueue());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -337,16 +337,6 @@ public:
|
||||
return moduleManager_;
|
||||
}
|
||||
|
||||
static constexpr uint32_t GetGlobalEnvOffset()
|
||||
{
|
||||
return MEMBER_OFFSET(EcmaVM, globalEnv_);
|
||||
}
|
||||
|
||||
static constexpr uint32_t GetMicroJobQueueOffset()
|
||||
{
|
||||
return MEMBER_OFFSET(EcmaVM, microJobQueue_);
|
||||
}
|
||||
|
||||
void SetupRegExpResultCache();
|
||||
JSHandle<JSTaggedValue> GetRegExpCache()
|
||||
{
|
||||
|
@ -269,8 +269,8 @@ JSTaggedValue FastRuntimeStub::AddPropertyByName(JSThread *thread, JSTaggedValue
|
||||
// change to dictionary and add one.
|
||||
JSHandle<NameDictionary> dict(JSObject::TransitionToDictionary(thread, objHandle));
|
||||
attr.SetDictionaryOrder(PropertyAttributes::MAX_CAPACITY_OF_PROPERTIES);
|
||||
auto result = JSTaggedValue(NameDictionary::PutIfAbsent(thread, dict, keyHandle, valueHandle, attr));
|
||||
objHandle->SetProperties(thread, result);
|
||||
NameDictionary *newDict = NameDictionary::PutIfAbsent(thread, dict, keyHandle, valueHandle, attr);
|
||||
objHandle->SetProperties(thread, JSTaggedValue(newDict));
|
||||
// index is not essential when fastMode is false;
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
@ -286,8 +286,8 @@ JSTaggedValue FastRuntimeStub::AddPropertyByName(JSThread *thread, JSTaggedValue
|
||||
array->Set(thread, outProps, valueHandle.GetTaggedValue());
|
||||
} else {
|
||||
JSHandle<NameDictionary> dictHandle(array);
|
||||
auto result = JSTaggedValue(NameDictionary::PutIfAbsent(thread, dictHandle, keyHandle, valueHandle, attr));
|
||||
objHandle->SetProperties(thread, result);
|
||||
NameDictionary *newDict = NameDictionary::PutIfAbsent(thread, dictHandle, keyHandle, valueHandle, attr);
|
||||
objHandle->SetProperties(thread, JSTaggedValue(newDict));
|
||||
}
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
@ -970,9 +970,9 @@ bool FastRuntimeStub::SetGlobalOwnProperty(JSThread *thread, JSTaggedValue recei
|
||||
PropertyBoxType boxType = valHandle->IsUndefined() ? PropertyBoxType::UNDEFINED : PropertyBoxType::CONSTANT;
|
||||
attr.SetBoxType(boxType);
|
||||
|
||||
objHandle->SetProperties(
|
||||
thread, JSTaggedValue(GlobalDictionary::PutIfAbsent(thread, dict_handle, keyHandle,
|
||||
JSHandle<JSTaggedValue>(boxHandle), attr)));
|
||||
GlobalDictionary *properties =
|
||||
GlobalDictionary::PutIfAbsent(thread, dict_handle, keyHandle, JSHandle<JSTaggedValue>(boxHandle), attr);
|
||||
objHandle->SetProperties(thread, JSTaggedValue(properties));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1020,9 +1020,9 @@ bool FastRuntimeStub::SetGlobalOwnProperty(JSThread *thread, JSTaggedValue recei
|
||||
PropertyBoxType boxType = valHandle->IsUndefined() ? PropertyBoxType::UNDEFINED : PropertyBoxType::CONSTANT;
|
||||
attr.SetBoxType(boxType);
|
||||
|
||||
objHandle->SetProperties(thread, JSTaggedValue(GlobalDictionary::PutIfAbsent(
|
||||
thread, dict_handle, keyHandle,
|
||||
JSHandle<JSTaggedValue>(boxHandle), attr)));
|
||||
GlobalDictionary *properties =
|
||||
GlobalDictionary::PutIfAbsent(thread, dict_handle, keyHandle, JSHandle<JSTaggedValue>(boxHandle), attr);
|
||||
objHandle->SetProperties(thread, JSTaggedValue(properties));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1439,8 +1439,9 @@ JSTaggedValue SlowRuntimeStub::StGlobalRecord(JSThread *thread, JSTaggedValue pr
|
||||
PropertyBoxType boxType = valueHandle->IsUndefined() ? PropertyBoxType::UNDEFINED : PropertyBoxType::CONSTANT;
|
||||
attributes.SetBoxType(boxType);
|
||||
|
||||
dict->PutIfAbsent(thread, dictHandle, propHandle, JSHandle<JSTaggedValue>(box), attributes);
|
||||
dict = GlobalDictionary::PutIfAbsent(thread, dictHandle, propHandle, JSHandle<JSTaggedValue>(box), attributes);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
env->SetGlobalRecord(thread, JSTaggedValue(dict));
|
||||
return JSTaggedValue::True();
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@
|
||||
#include "utils/expected.h"
|
||||
|
||||
namespace panda::ecmascript::job {
|
||||
void MicroJobQueue::EnqueueJob(JSThread *thread, QueueType queueType, const JSHandle<JSFunction> &job,
|
||||
const JSHandle<TaggedArray> &argv)
|
||||
void MicroJobQueue::EnqueueJob(JSThread *thread, JSHandle<MicroJobQueue> jobQueue, QueueType queueType,
|
||||
const JSHandle<JSFunction> &job, const JSHandle<TaggedArray> &argv)
|
||||
{
|
||||
// 1. Assert: Type(queueName) is String and its value is the name of a Job Queue recognized by this implementation.
|
||||
// 2. Assert: job is the name of a Job.
|
||||
@ -39,24 +39,22 @@ void MicroJobQueue::EnqueueJob(JSThread *thread, QueueType queueType, const JSHa
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
JSHandle<PendingJob> pendingJob(factory->NewPendingJob(job, argv));
|
||||
if (queueType == QueueType::QUEUE_PROMISE) {
|
||||
JSHandle<TaggedQueue> promiseQueue(thread, GetPromiseJobQueue());
|
||||
JSHandle<TaggedQueue> promiseQueue(thread, jobQueue->GetPromiseJobQueue());
|
||||
LOG_ECMA(DEBUG) << "promiseQueue start length: " << promiseQueue->Size();
|
||||
JSHandle<TaggedQueue> newPromiseQueue(
|
||||
thread, TaggedQueue::Push(thread, promiseQueue, JSHandle<JSTaggedValue>::Cast(pendingJob)));
|
||||
SetPromiseJobQueue(thread, newPromiseQueue.GetTaggedValue());
|
||||
TaggedQueue *newPromiseQueue = TaggedQueue::Push(thread, promiseQueue, JSHandle<JSTaggedValue>(pendingJob));
|
||||
jobQueue->SetPromiseJobQueue(thread, JSTaggedValue(newPromiseQueue));
|
||||
LOG_ECMA(DEBUG) << "promiseQueue end length: " << newPromiseQueue->Size();
|
||||
} else if (queueType == QueueType::QUEUE_SCRIPT) {
|
||||
JSHandle<TaggedQueue> scriptQueue(thread, GetScriptJobQueue());
|
||||
JSHandle<TaggedQueue> newScriptQueue(
|
||||
thread, TaggedQueue::Push(thread, scriptQueue, JSHandle<JSTaggedValue>::Cast(pendingJob)));
|
||||
SetScriptJobQueue(thread, newScriptQueue.GetTaggedValue());
|
||||
JSHandle<TaggedQueue> scriptQueue(thread, jobQueue->GetScriptJobQueue());
|
||||
TaggedQueue *newScriptQueue = TaggedQueue::Push(thread, scriptQueue, JSHandle<JSTaggedValue>(pendingJob));
|
||||
jobQueue->SetScriptJobQueue(thread, JSTaggedValue(newScriptQueue));
|
||||
}
|
||||
}
|
||||
|
||||
void MicroJobQueue::ExecutePendingJob(JSThread *thread)
|
||||
void MicroJobQueue::ExecutePendingJob(JSThread *thread, JSHandle<MicroJobQueue> jobQueue)
|
||||
{
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
JSHandle<TaggedQueue> promiseQueue(thread, GetPromiseJobQueue());
|
||||
JSMutableHandle<TaggedQueue> promiseQueue(thread, jobQueue->GetPromiseJobQueue());
|
||||
JSMutableHandle<PendingJob> pendingJob(thread, JSTaggedValue::Undefined());
|
||||
while (!promiseQueue->Empty()) {
|
||||
LOG_ECMA(DEBUG) << "promiseQueue start length: " << promiseQueue->Size();
|
||||
@ -66,10 +64,10 @@ void MicroJobQueue::ExecutePendingJob(JSThread *thread)
|
||||
if (thread->HasPendingException()) {
|
||||
return;
|
||||
}
|
||||
promiseQueue = JSHandle<TaggedQueue>(thread, GetPromiseJobQueue());
|
||||
promiseQueue.Update(jobQueue->GetPromiseJobQueue());
|
||||
}
|
||||
|
||||
JSHandle<TaggedQueue> scriptQueue(thread, GetScriptJobQueue());
|
||||
JSHandle<TaggedQueue> scriptQueue(thread, jobQueue->GetScriptJobQueue());
|
||||
while (!scriptQueue->Empty()) {
|
||||
pendingJob.Update(scriptQueue->Pop(thread));
|
||||
PendingJob::ExecutePendingJob(pendingJob, thread);
|
||||
|
@ -40,9 +40,9 @@ public:
|
||||
return static_cast<MicroJobQueue *>(object);
|
||||
}
|
||||
|
||||
void EnqueueJob(JSThread *thread, QueueType queueType, const JSHandle<JSFunction> &job,
|
||||
const JSHandle<TaggedArray> &argv);
|
||||
void ExecutePendingJob(JSThread *thread);
|
||||
static void EnqueueJob(JSThread *thread, JSHandle<MicroJobQueue> jobQueue, QueueType queueType,
|
||||
const JSHandle<JSFunction> &job, const JSHandle<TaggedArray> &argv);
|
||||
static void ExecutePendingJob(JSThread *thread, JSHandle<MicroJobQueue> jobQueue);
|
||||
|
||||
static constexpr size_t PROMISE_JOB_QUEUE_OFFSET = Record::SIZE;
|
||||
ACCESSORS(PromiseJobQueue, PROMISE_JOB_QUEUE_OFFSET, SCRIPT_JOB_QUEUE_OFFSET);
|
||||
|
@ -190,8 +190,8 @@ void JSArray::SetCapacity(JSThread *thread, const JSHandle<JSObject> &array, uin
|
||||
uint32_t attr = dictHandle->GetAttributes(entry).GetValue();
|
||||
PropertyAttributes propAttr(attr);
|
||||
if (propAttr.IsConfigurable()) {
|
||||
NumberDictionary *dictionary = NumberDictionary::Remove(thread, dictHandle, entry);
|
||||
array->SetElements(thread, JSTaggedValue(dictionary));
|
||||
NumberDictionary *newDict = NumberDictionary::Remove(thread, dictHandle, entry);
|
||||
array->SetElements(thread, JSTaggedValue(newDict));
|
||||
if (i == 0) {
|
||||
newNumOfElements = i;
|
||||
break;
|
||||
|
@ -197,7 +197,8 @@ void JSForInIterator::SlowGetAllEnumKeys(JSThread *thread, const JSHandle<JSForI
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
value.Update(arr->Get(i));
|
||||
if (value->IsString()) {
|
||||
remaining.Update(JSTaggedValue(TaggedQueue::Push(thread, remaining, value)));
|
||||
TaggedQueue *newQueue = TaggedQueue::Push(thread, remaining, value);
|
||||
remaining.Update(JSTaggedValue(newQueue));
|
||||
}
|
||||
}
|
||||
it->SetRemainingKeys(thread, remaining);
|
||||
@ -244,9 +245,9 @@ std::pair<JSTaggedValue, bool> JSForInIterator::NextInternal(JSThread *thread, c
|
||||
PropertyDescriptor desc(thread);
|
||||
bool has = JSTaggedValue::GetOwnProperty(thread, object, key, desc);
|
||||
if (has) {
|
||||
auto queue = JSTaggedValue(TaggedQueue::Push(thread, visited, key));
|
||||
visited.Update(queue);
|
||||
it->SetVisitedKeys(thread, queue);
|
||||
auto newQueue = JSTaggedValue(TaggedQueue::Push(thread, visited, key));
|
||||
visited.Update(newQueue);
|
||||
it->SetVisitedKeys(thread, newQueue);
|
||||
if (desc.IsEnumerable()) {
|
||||
return std::make_pair(key.GetTaggedValue(), false);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ void JSHClass::AddTransitions(const JSThread *thread, const JSHandle<JSHClass> &
|
||||
child->SetParent(thread, parent.GetTaggedValue());
|
||||
return;
|
||||
}
|
||||
JSMutableHandle<TransitionsDictionary> dict(thread, JSTaggedValue::Undefined());
|
||||
if (transitions.IsJSHClass()) {
|
||||
auto cachedHClass = JSHClass::Cast(transitions.GetTaggedObject());
|
||||
int last = cachedHClass->GetPropertiesNumber() - 1;
|
||||
@ -45,11 +46,11 @@ void JSHClass::AddTransitions(const JSThread *thread, const JSHandle<JSHClass> &
|
||||
auto attr = JSHandle<JSTaggedValue>(thread, JSTaggedValue(layoutInfo->GetAttr(last).GetPropertyMetaData()));
|
||||
auto lastKey = JSHandle<JSTaggedValue>(thread, layoutInfo->GetKey(last));
|
||||
auto lastHClass = JSHandle<JSTaggedValue>(thread, cachedHClass);
|
||||
auto dict = JSHandle<TransitionsDictionary>(thread, TransitionsDictionary::Create(thread));
|
||||
dict.Update(JSTaggedValue(TransitionsDictionary::Create(thread)));
|
||||
transitions = JSTaggedValue(TransitionsDictionary::PutIfAbsent(thread, dict, lastKey, lastHClass, attr));
|
||||
}
|
||||
auto attr = JSHandle<JSTaggedValue>(thread, JSTaggedValue(attributes.GetPropertyMetaData()));
|
||||
JSHandle<TransitionsDictionary> dict(thread, transitions);
|
||||
dict.Update(transitions);
|
||||
transitions =
|
||||
JSTaggedValue(TransitionsDictionary::PutIfAbsent(thread, dict, key, JSHandle<JSTaggedValue>(child), attr));
|
||||
parent->SetTransitions(thread, transitions);
|
||||
@ -68,6 +69,7 @@ void JSHClass::AddProtoTransitions(const JSThread *thread, const JSHandle<JSHCla
|
||||
const JSHandle<JSTaggedValue> &proto)
|
||||
{
|
||||
JSTaggedValue transitions = parent->GetTransitions();
|
||||
JSMutableHandle<TransitionsDictionary> dict(thread, JSTaggedValue::Undefined());
|
||||
if (transitions.IsNull()) {
|
||||
transitions = JSTaggedValue(TransitionsDictionary::Create(thread));
|
||||
} else if (transitions.IsJSHClass()) {
|
||||
@ -77,11 +79,11 @@ void JSHClass::AddProtoTransitions(const JSThread *thread, const JSHandle<JSHCla
|
||||
auto attr = JSHandle<JSTaggedValue>(thread, JSTaggedValue(layoutInfo->GetAttr(last).GetPropertyMetaData()));
|
||||
auto lastKey = JSHandle<JSTaggedValue>(thread, layoutInfo->GetKey(last));
|
||||
auto lastHClass = JSHandle<JSTaggedValue>(thread, cachedHClass);
|
||||
auto dict = JSHandle<TransitionsDictionary>(thread, TransitionsDictionary::Create(thread));
|
||||
dict.Update(JSTaggedValue(TransitionsDictionary::Create(thread)));
|
||||
transitions = JSTaggedValue(TransitionsDictionary::PutIfAbsent(thread, dict, lastKey, lastHClass, attr));
|
||||
}
|
||||
|
||||
JSHandle<TransitionsDictionary> dict(thread, transitions);
|
||||
dict.Update(transitions);
|
||||
transitions =
|
||||
JSTaggedValue(TransitionsDictionary::PutIfAbsent(thread, dict, key, JSHandle<JSTaggedValue>(child), proto));
|
||||
parent->SetTransitions(thread, transitions);
|
||||
|
@ -28,8 +28,8 @@ void JSMap::Set(JSThread *thread, const JSHandle<JSMap> &map, const JSHandle<JST
|
||||
}
|
||||
JSHandle<LinkedHashMap> mapHandle(thread, LinkedHashMap::Cast(map->GetLinkedMap().GetTaggedObject()));
|
||||
|
||||
auto result = LinkedHashMap::Set(thread, mapHandle, key, value);
|
||||
map->SetLinkedMap(thread, result);
|
||||
JSTaggedValue newMap = LinkedHashMap::Set(thread, mapHandle, key, value);
|
||||
map->SetLinkedMap(thread, newMap);
|
||||
}
|
||||
|
||||
bool JSMap::Delete(const JSThread *thread, const JSHandle<JSMap> &map, const JSHandle<JSTaggedValue> &key)
|
||||
@ -41,8 +41,8 @@ bool JSMap::Delete(const JSThread *thread, const JSHandle<JSMap> &map, const JSH
|
||||
}
|
||||
mapHandle->RemoveEntry(thread, entry);
|
||||
|
||||
auto result = LinkedHashMap::Shrink(thread, mapHandle);
|
||||
map->SetLinkedMap(thread, result);
|
||||
JSTaggedValue newMap = LinkedHashMap::Shrink(thread, mapHandle);
|
||||
map->SetLinkedMap(thread, newMap);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,8 @@ JSHandle<NameDictionary> JSObject::TransitionToDictionary(const JSThread *thread
|
||||
attr.SetBoxType(PropertyBoxType::UNDEFINED);
|
||||
valueHandle.Update(value);
|
||||
keyHandle.Update(key);
|
||||
dict.Update(JSTaggedValue(NameDictionary::PutIfAbsent(thread, dict, keyHandle, valueHandle, attr)));
|
||||
NameDictionary *newDict = NameDictionary::PutIfAbsent(thread, dict, keyHandle, valueHandle, attr);
|
||||
dict.Update(JSTaggedValue(newDict));
|
||||
}
|
||||
|
||||
receiver->SetProperties(thread, dict);
|
||||
@ -152,7 +153,8 @@ void JSObject::ElementsToDictionary(const JSThread *thread, JSHandle<JSObject> o
|
||||
}
|
||||
key.Update(JSTaggedValue(i));
|
||||
valueHandle.Update(value);
|
||||
dict.Update(JSTaggedValue(NumberDictionary::PutIfAbsent(thread, dict, key, valueHandle, attr)));
|
||||
NumberDictionary *newDict = NumberDictionary::PutIfAbsent(thread, dict, key, valueHandle, attr);
|
||||
dict.Update(JSTaggedValue(newDict));
|
||||
}
|
||||
obj->SetElements(thread, dict);
|
||||
|
||||
@ -193,9 +195,9 @@ bool JSObject::AddElementInternal(JSThread *thread, const JSHandle<JSObject> &re
|
||||
if (isDictionary) {
|
||||
ASSERT(elements->IsDictionaryMode());
|
||||
JSHandle<JSTaggedValue> keyHandle(thread, JSTaggedValue(static_cast<int32_t>(index)));
|
||||
NumberDictionary *dict =
|
||||
NumberDictionary *newDict =
|
||||
NumberDictionary::Put(thread, JSHandle<NumberDictionary>(thread, elements), keyHandle, value, attr);
|
||||
receiver->SetElements(thread, JSTaggedValue(dict));
|
||||
receiver->SetElements(thread, JSTaggedValue(newDict));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -205,8 +207,8 @@ bool JSObject::AddElementInternal(JSThread *thread, const JSHandle<JSObject> &re
|
||||
JSObject::ElementsToDictionary(thread, receiver);
|
||||
JSHandle<JSTaggedValue> keyHandle(thread, JSTaggedValue(static_cast<int32_t>(index)));
|
||||
JSHandle<NumberDictionary> dict(thread, receiver->GetElements());
|
||||
auto key = JSTaggedValue(NumberDictionary::Put(thread, dict, keyHandle, value, attr));
|
||||
receiver->SetElements(thread, key);
|
||||
NumberDictionary *newKey = NumberDictionary::Put(thread, dict, keyHandle, value, attr);
|
||||
receiver->SetElements(thread, JSTaggedValue(newKey));
|
||||
return true;
|
||||
}
|
||||
elements = *JSObject::GrowElementsCapacity(thread, receiver, index + 1);
|
||||
@ -223,8 +225,8 @@ void JSObject::DeletePropertyInternal(JSThread *thread, const JSHandle<JSObject>
|
||||
|
||||
if (obj->IsJSGlobalObject()) {
|
||||
JSHandle<GlobalDictionary> dictHandle(thread, obj->GetProperties());
|
||||
GlobalDictionary *dict = GlobalDictionary::Remove(thread, dictHandle, index);
|
||||
obj->SetProperties(thread, JSTaggedValue(dict));
|
||||
GlobalDictionary *newDict = GlobalDictionary::Remove(thread, dictHandle, index);
|
||||
obj->SetProperties(thread, JSTaggedValue(newDict));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -232,14 +234,14 @@ void JSObject::DeletePropertyInternal(JSThread *thread, const JSHandle<JSObject>
|
||||
JSHandle<NameDictionary> dictHandle(TransitionToDictionary(thread, obj));
|
||||
int entry = dictHandle->FindEntry(key.GetTaggedValue());
|
||||
ASSERT(entry != -1);
|
||||
NameDictionary *dict = NameDictionary::Remove(thread, dictHandle, entry);
|
||||
obj->SetProperties(thread, JSTaggedValue(dict));
|
||||
NameDictionary *newDict = NameDictionary::Remove(thread, dictHandle, entry);
|
||||
obj->SetProperties(thread, JSTaggedValue(newDict));
|
||||
return;
|
||||
}
|
||||
|
||||
JSHandle<NameDictionary> dictHandle(array);
|
||||
NameDictionary *dict = NameDictionary::Remove(thread, dictHandle, index);
|
||||
obj->SetProperties(thread, JSTaggedValue(dict));
|
||||
NameDictionary *newDict = NameDictionary::Remove(thread, dictHandle, index);
|
||||
obj->SetProperties(thread, JSTaggedValue(newDict));
|
||||
}
|
||||
|
||||
void JSObject::GetAllKeys(const JSThread *thread, const JSHandle<JSObject> &obj, int offset,
|
||||
|
@ -178,7 +178,7 @@ JSTaggedValue JSPromise::TriggerPromiseReactions(JSThread *thread, const JSHandl
|
||||
JSHandle<TaggedArray> arguments = factory->NewTaggedArray(2); // 2 means the length of new array
|
||||
arguments->Set(thread, 0, reaction);
|
||||
arguments->Set(thread, 1, argument);
|
||||
job->EnqueueJob(thread, job::QueueType::QUEUE_PROMISE, promiseReactionsJob, arguments);
|
||||
job::MicroJobQueue::EnqueueJob(thread, job, job::QueueType::QUEUE_PROMISE, promiseReactionsJob, arguments);
|
||||
}
|
||||
// 2. Return undefined.
|
||||
return globalConst->GetUndefined();
|
||||
|
@ -28,8 +28,8 @@ void JSSet::Add(JSThread *thread, const JSHandle<JSSet> &set, const JSHandle<JST
|
||||
}
|
||||
JSHandle<LinkedHashSet> setHandle(thread, LinkedHashSet::Cast(set->GetLinkedSet().GetTaggedObject()));
|
||||
|
||||
auto table = LinkedHashSet::Add(thread, setHandle, value);
|
||||
set->SetLinkedSet(thread, table);
|
||||
JSTaggedValue newSet = LinkedHashSet::Add(thread, setHandle, value);
|
||||
set->SetLinkedSet(thread, newSet);
|
||||
}
|
||||
|
||||
bool JSSet::Delete(const JSThread *thread, const JSHandle<JSSet> &set, const JSHandle<JSTaggedValue> &value)
|
||||
@ -40,8 +40,8 @@ bool JSSet::Delete(const JSThread *thread, const JSHandle<JSSet> &set, const JSH
|
||||
return false;
|
||||
}
|
||||
setHandle->RemoveEntry(thread, entry);
|
||||
auto table = LinkedHashSet::Shrink(thread, setHandle);
|
||||
set->SetLinkedSet(thread, table);
|
||||
JSTaggedValue newSet = LinkedHashSet::Shrink(thread, setHandle);
|
||||
set->SetLinkedSet(thread, newSet);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@ void JSWeakMap::Set(JSThread *thread, const JSHandle<JSWeakMap> &map, const JSHa
|
||||
}
|
||||
JSHandle<LinkedHashMap> mapHandle(thread, LinkedHashMap::Cast(map->GetLinkedMap().GetTaggedObject()));
|
||||
|
||||
auto result = LinkedHashMap::SetWeakRef(thread, mapHandle, key, value);
|
||||
map->SetLinkedMap(thread, result);
|
||||
JSTaggedValue newMap = LinkedHashMap::SetWeakRef(thread, mapHandle, key, value);
|
||||
map->SetLinkedMap(thread, newMap);
|
||||
}
|
||||
|
||||
bool JSWeakMap::Delete(JSThread *thread, const JSHandle<JSWeakMap> &map, const JSHandle<JSTaggedValue> &key)
|
||||
@ -43,8 +43,8 @@ bool JSWeakMap::Delete(JSThread *thread, const JSHandle<JSWeakMap> &map, const J
|
||||
}
|
||||
mapHandle->RemoveEntry(thread, entry);
|
||||
|
||||
auto result = LinkedHashMap::Shrink(thread, mapHandle);
|
||||
map->SetLinkedMap(thread, result);
|
||||
JSTaggedValue newMap = LinkedHashMap::Shrink(thread, mapHandle);
|
||||
map->SetLinkedMap(thread, newMap);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -70,8 +70,8 @@ void JSWeakSet::Add(JSThread *thread, const JSHandle<JSWeakSet> &weakSet, const
|
||||
}
|
||||
JSHandle<LinkedHashSet> weakSetHandle(thread, LinkedHashSet::Cast(weakSet->GetLinkedSet().GetTaggedObject()));
|
||||
|
||||
auto result = LinkedHashSet::AddWeakRef(thread, weakSetHandle, value);
|
||||
weakSet->SetLinkedSet(thread, result);
|
||||
JSTaggedValue newSet = LinkedHashSet::AddWeakRef(thread, weakSetHandle, value);
|
||||
weakSet->SetLinkedSet(thread, newSet);
|
||||
}
|
||||
|
||||
bool JSWeakSet::Delete(JSThread *thread, const JSHandle<JSWeakSet> &weakSet, const JSHandle<JSTaggedValue> &value)
|
||||
@ -82,8 +82,8 @@ bool JSWeakSet::Delete(JSThread *thread, const JSHandle<JSWeakSet> &weakSet, con
|
||||
return false;
|
||||
}
|
||||
weakSetHandle->RemoveEntry(thread, entry);
|
||||
auto result = LinkedHashSet::Shrink(thread, weakSetHandle);
|
||||
weakSet->SetLinkedSet(thread, result);
|
||||
JSTaggedValue newSet = LinkedHashSet::Shrink(thread, weakSetHandle);
|
||||
weakSet->SetLinkedSet(thread, newSet);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -568,8 +568,8 @@ void ObjectOperator::DeleteElementInHolder() const
|
||||
JSObject::ElementsToDictionary(thread_, JSHandle<JSObject>(holder_));
|
||||
} else {
|
||||
JSHandle<NumberDictionary> dictHandle(thread_, elements);
|
||||
NumberDictionary *dict = NumberDictionary::Remove(thread_, dictHandle, GetIndex());
|
||||
obj->SetElements(thread_, JSTaggedValue(dict));
|
||||
NumberDictionary *newDict = NumberDictionary::Remove(thread_, dictHandle, GetIndex());
|
||||
obj->SetElements(thread_, JSTaggedValue(newDict));
|
||||
}
|
||||
}
|
||||
|
||||
@ -661,9 +661,9 @@ void ObjectOperator::AddPropertyInternal(const JSHandle<JSTaggedValue> &value)
|
||||
PropertyBoxType cellType = value->IsUndefined() ? PropertyBoxType::UNDEFINED : PropertyBoxType::CONSTANT;
|
||||
attr.SetBoxType(cellType);
|
||||
|
||||
JSTaggedValue properties(
|
||||
GlobalDictionary::PutIfAbsent(thread_, dict, key_, JSHandle<JSTaggedValue>(cellHandle), attr));
|
||||
obj->SetProperties(thread_, properties);
|
||||
GlobalDictionary *properties =
|
||||
GlobalDictionary::PutIfAbsent(thread_, dict, key_, JSHandle<JSTaggedValue>(cellHandle), attr);
|
||||
obj->SetProperties(thread_, JSTaggedValue(properties));
|
||||
// index and fastMode is not essential for global obj;
|
||||
SetFound(0, cellHandle.GetTaggedValue(), attr.GetValue(), true);
|
||||
return;
|
||||
@ -704,8 +704,8 @@ void ObjectOperator::AddPropertyInternal(const JSHandle<JSTaggedValue> &value)
|
||||
// change to dictionary and add one.
|
||||
JSHandle<NameDictionary> dict(JSObject::TransitionToDictionary(thread_, obj));
|
||||
attr.SetDictionaryOrder(PropertyAttributes::MAX_CAPACITY_OF_PROPERTIES);
|
||||
auto result = JSTaggedValue(NameDictionary::PutIfAbsent(thread_, dict, key_, value, attr));
|
||||
obj->SetProperties(thread_, result);
|
||||
NameDictionary *newDict = NameDictionary::PutIfAbsent(thread_, dict, key_, value, attr);
|
||||
obj->SetProperties(thread_, JSTaggedValue(newDict));
|
||||
// index is not essential when fastMode is false;
|
||||
SetFound(0, value.GetTaggedValue(), attr.GetValue(), false);
|
||||
return;
|
||||
@ -724,8 +724,8 @@ void ObjectOperator::AddPropertyInternal(const JSHandle<JSTaggedValue> &value)
|
||||
}
|
||||
|
||||
JSHandle<NameDictionary> dictHandle(array);
|
||||
auto result = JSTaggedValue(NameDictionary::PutIfAbsent(thread_, dictHandle, key_, value, attr));
|
||||
obj->SetProperties(thread_, result);
|
||||
NameDictionary *newDict = NameDictionary::PutIfAbsent(thread_, dictHandle, key_, value, attr);
|
||||
obj->SetProperties(thread_, JSTaggedValue(newDict));
|
||||
SetFound(0, value.GetTaggedValue(), attr.GetValue(), false);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ HWTEST_F_L0(NameDictionaryTest, addKeyAndValue)
|
||||
int numOfElement = 64;
|
||||
JSHandle<NameDictionary> dictJShandle(thread, NameDictionary::Create(thread, numOfElement));
|
||||
EXPECT_TRUE(*dictJShandle != nullptr);
|
||||
JSHandle<NameDictionary> dictHandle(dictJShandle);
|
||||
JSMutableHandle<NameDictionary> dictHandle(dictJShandle);
|
||||
JSHandle<JSTaggedValue> objFun = GetGlobalEnv(thread)->GetObjectFunction();
|
||||
|
||||
// create key and values
|
||||
@ -103,7 +103,8 @@ HWTEST_F_L0(NameDictionaryTest, addKeyAndValue)
|
||||
PropertyAttributes metaData2;
|
||||
|
||||
// test insert()
|
||||
JSHandle<NameDictionary> dict(thread, NameDictionary::PutIfAbsent(thread, dictHandle, key1, value1, metaData1));
|
||||
NameDictionary *dict = NameDictionary::PutIfAbsent(thread, dictHandle, key1, value1, metaData1);
|
||||
dictHandle.Update(JSTaggedValue(dict));
|
||||
EXPECT_EQ(dict->EntriesCount(), 1);
|
||||
|
||||
// test find() and lookup()
|
||||
@ -111,10 +112,10 @@ HWTEST_F_L0(NameDictionaryTest, addKeyAndValue)
|
||||
EXPECT_EQ(key1.GetTaggedValue(), JSTaggedValue(dict->GetKey(entry1).GetRawData()));
|
||||
EXPECT_EQ(value1.GetTaggedValue(), JSTaggedValue(dict->GetValue(entry1).GetRawData()));
|
||||
|
||||
JSHandle<NameDictionary> dict2(thread, dict->PutIfAbsent(thread, dictHandle, key2, value2, metaData2));
|
||||
JSHandle<NameDictionary> dict2(thread, NameDictionary::PutIfAbsent(thread, dictHandle, key2, value2, metaData2));
|
||||
EXPECT_EQ(dict2->EntriesCount(), 2);
|
||||
// test remove()
|
||||
dict->Remove(thread, dictHandle, entry1);
|
||||
dict = NameDictionary::Remove(thread, dictHandle, entry1);
|
||||
EXPECT_EQ(-1, dict->FindEntry(key1.GetTaggedValue()));
|
||||
EXPECT_EQ(dict->EntriesCount(), 1);
|
||||
}
|
||||
@ -172,7 +173,8 @@ HWTEST_F_L0(NameDictionaryTest, ShrinkCapacity)
|
||||
PropertyAttributes metaData;
|
||||
|
||||
// test insert()
|
||||
dictHandle.Update(JSTaggedValue(NameDictionary::PutIfAbsent(thread, dictHandle, key, value, metaData)));
|
||||
NameDictionary *newDict = NameDictionary::PutIfAbsent(thread, dictHandle, key, value, metaData);
|
||||
dictHandle.Update(JSTaggedValue(newDict));
|
||||
}
|
||||
|
||||
keyArray[5] = '2';
|
||||
@ -183,7 +185,8 @@ HWTEST_F_L0(NameDictionaryTest, ShrinkCapacity)
|
||||
int entry = dictHandle->FindEntry(arrayHandle.GetTaggedValue());
|
||||
EXPECT_NE(entry, -1);
|
||||
|
||||
dictHandle.Update(JSTaggedValue(NameDictionary::Remove(thread, dictHandle, entry)));
|
||||
NameDictionary *newDict1 = NameDictionary::Remove(thread, dictHandle, entry);
|
||||
dictHandle.Update(JSTaggedValue(newDict1));
|
||||
EXPECT_EQ(dictHandle->EntriesCount(), 9);
|
||||
EXPECT_EQ(dictHandle->Size(), 16);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ JSTaggedValue WeakVector::Get(array_size_t index) const
|
||||
void WeakVector::Set(const JSThread *thread, array_size_t index, JSTaggedValue value)
|
||||
{
|
||||
ASSERT(index < GetCapacity());
|
||||
return TaggedArray::Set(thread, VectorToArrayIndex(index), value);
|
||||
TaggedArray::Set(thread, VectorToArrayIndex(index), value);
|
||||
}
|
||||
|
||||
void WeakVector::SetEnd(const JSThread *thread, array_size_t end)
|
||||
|
Loading…
Reference in New Issue
Block a user