Lines Matching refs:thread
24 JSTaggedValue JSSharedArray::LengthGetter([[maybe_unused]] JSThread *thread, const JSHandle<JSObject> &self,
27 [[maybe_unused]] ConcurrentApiScope<JSSharedArray> scope(thread, JSHandle<JSTaggedValue>::Cast(self),
29 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
33 bool JSSharedArray::DummyLengthSetter([[maybe_unused]] JSThread *thread,
42 bool JSSharedArray::LengthSetter(JSThread *thread, const JSHandle<JSObject> &self, const JSHandle<JSTaggedValue> &value,
45 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false);
47 if (!JSTaggedValue::ToArrayLength(thread, value, &newLen) && mayThrow) {
48 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false);
56 if (!IsArrayLengthWritable(thread, self)) {
58 THROW_TYPE_ERROR_AND_RETURN(thread, GET_MESSAGE_STRING(SetReadOnlyProperty), false);
63 JSSharedArray::SetCapacity(thread, self, oldLen, newLen);
67 THROW_TYPE_ERROR_AND_RETURN(thread, "Not all array elements is configurable", false);
75 JSHandle<JSTaggedValue> JSSharedArray::ArrayCreate(JSThread *thread, JSTaggedNumber length, ArrayMode mode)
77 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
79 return JSSharedArray::ArrayCreate(thread, length, sharedArrayFunction, mode);
83 JSHandle<JSTaggedValue> JSSharedArray::ArrayCreate(JSThread *thread, JSTaggedNumber length,
86 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
92 JSHandle<JSTaggedValue> exception(thread, JSTaggedValue::Exception());
93 auto error = containers::ContainerError::BusinessError(thread, containers::ErrorFlag::TYPE_ERROR,
95 THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, exception);
100 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
103 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
109 JSSharedArray::Cast(*obj)->SetArrayLength(thread, normalArrayLength);
111 JSSharedArray::SetCapacity(thread, obj, 0, normalArrayLength, true);
117 JSTaggedValue JSSharedArray::ArraySpeciesCreate(JSThread *thread, const JSHandle<JSObject> &originalArray,
120 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
121 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
134 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
136 JSHandle<JSTaggedValue> constructor(thread, JSTaggedValue::Undefined());
142 return JSSharedArray::ArrayCreate(thread, length).GetTaggedValue();
145 constructor = JSTaggedValue::GetProperty(thread, originalValue, constructorKey).GetValue();
147 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
152 JSHandle<GlobalEnv> realmC = JSObject::GetFunctionRealm(thread, constructor);
154 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
160 return JSSharedArray::ArrayCreate(thread, length).GetTaggedValue();
169 constructor = JSTaggedValue::GetProperty(thread, constructor, speciesSymbol).GetValue();
171 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
174 return JSSharedArray::ArrayCreate(thread, length).GetTaggedValue();
181 return JSSharedArray::ArrayCreate(thread, length).GetTaggedValue();
185 THROW_TYPE_ERROR_AND_RETURN(thread, "Not a constructor", JSTaggedValue::Exception());
188 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
190 EcmaInterpreter::NewRuntimeCallInfo(thread, constructor, undefined, undefined, 1);
191 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
194 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
204 JSHandle<TaggedArray> JSSharedArray::SetCapacity(const JSThread *thread, const JSHandle<TaggedArray> &array,
207 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
213 void JSSharedArray::SetCapacity(JSThread *thread, const JSHandle<JSObject> &array, uint32_t oldLen, uint32_t newLen,
219 THROW_TYPE_ERROR(thread, "SendableArray don't support dictionary mode.");
224 CheckAndCopyArray(thread, JSHandle<JSSharedArray>(array));
225 array->FillElementsWithHoles(thread, newLen, oldLen < capacity ? oldLen : capacity);
228 JSObject::GrowElementsCapacity(thread, array, newLen, isNew);
230 JSSharedArray::Cast(*array)->SetArrayLength(thread, newLen);
233 bool JSSharedArray::ArraySetLength(JSThread *thread, const JSHandle<JSObject> &array, const PropertyDescriptor &desc)
235 JSHandle<JSTaggedValue> lengthKeyHandle(thread->GlobalConstants()->GetHandledLengthString());
240 return JSObject::OrdinaryDefineOwnProperty(thread, array, lengthKeyHandle, desc);
247 if (!JSTaggedValue::ToArrayLength(thread, desc.GetValue(), &newLen)) {
248 THROW_RANGE_ERROR_AND_RETURN(thread, "array length must equal or less than 2^32.", false);
253 PropertyDescriptor oldLenDesc(thread);
254 [[maybe_unused]] bool success = GetOwnProperty(thread, array, lengthKeyHandle, oldLenDesc);
260 JSTaggedValue::ToArrayLength(thread, oldLenDesc.GetValue(), &oldLen);
265 newLenDesc.SetValue(JSHandle<JSTaggedValue>(thread, JSTaggedValue(newLen)));
266 return JSObject::OrdinaryDefineOwnProperty(thread, array, lengthKeyHandle, newLenDesc);
292 JSSharedArray::SetCapacity(thread, array, oldLen, newLen);
295 PropertyDescriptor readonly(thread);
297 success = JSObject::DefineOwnProperty(thread, array, lengthKeyHandle, readonly);
306 bool JSSharedArray::PropertyKeyToArrayIndex(JSThread *thread, const JSHandle<JSTaggedValue> &key, uint32_t *output)
308 return JSTaggedValue::ToArrayLength(thread, key, output) && *output <= JSSharedArray::MAX_ARRAY_INDEX;
312 bool JSSharedArray::DefineOwnProperty(JSThread *thread, const JSHandle<JSObject> &array,
318 auto error = containers::ContainerError::BusinessError(thread, containers::ErrorFlag::TYPE_ERROR,
320 THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, false);
324 auto error = containers::ContainerError::BusinessError(thread, containers::ErrorFlag::RANGE_ERROR,
326 THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, false);
332 if (IsLengthString(thread, key)) {
334 return ArraySetLength(thread, array, desc);
340 bool success = JSObject::OrdinaryDefineOwnProperty(thread, array, key, desc);
342 JSTaggedValue constructorKey = thread->GlobalConstants()->GetConstructorString();
351 bool JSSharedArray::IsLengthString(JSThread *thread, const JSHandle<JSTaggedValue> &key)
353 return key.GetTaggedValue() == thread->GlobalConstants()->GetLengthString();
356 JSHandle<JSSharedArray> JSSharedArray::CreateArrayFromList(JSThread *thread, const JSHandle<TaggedArray> &elements)
363 auto env = thread->GetEcmaVM()->GetGlobalEnv();
364 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
367 JSSharedArray::Cast(*obj)->SetArrayLength(thread, length);
368 obj->SetElements(thread, elements);
375 JSHandle<JSTaggedValue> JSSharedArray::FastGetPropertyByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
378 auto result = ObjectFastOperator::FastGetPropertyByIndex(thread, obj.GetTaggedValue(), index);
379 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
380 return JSHandle<JSTaggedValue>(thread, result);
383 JSHandle<JSTaggedValue> JSSharedArray::FastGetPropertyByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
387 ObjectFastOperator::FastGetPropertyByValue(thread, obj.GetTaggedValue(), key.GetTaggedValue(), sCheckMode);
388 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
389 return JSHandle<JSTaggedValue>(thread, result);
392 bool JSSharedArray::FastSetPropertyByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj, uint32_t index,
395 return ObjectFastOperator::FastSetPropertyByIndex(thread, obj.GetTaggedValue(), index, value.GetTaggedValue());
398 bool JSSharedArray::FastSetPropertyByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
401 return ObjectFastOperator::FastSetPropertyByValue(thread, obj.GetTaggedValue(), key.GetTaggedValue(),
405 OperationResult JSSharedArray::GetProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
409 [[maybe_unused]] ConcurrentApiScope<JSSharedArray> scope(thread, obj,
411 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread,
412 OperationResult(thread, JSTaggedValue::Exception(), PropertyMetaData(false)));
414 ObjectOperator op(thread, obj, key);
417 return OperationResult(thread, JSTaggedValue::Undefined(), PropertyMetaData(false));
419 return OperationResult(thread, JSObject::GetProperty(thread, &op), PropertyMetaData(op.IsFound()));
422 bool JSSharedArray::SetProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
428 thread, obj, sCheckMode);
429 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false);
431 ObjectOperator op(thread, obj, key);
434 auto error = containers::ContainerError::BusinessError(thread, containers::ErrorFlag::RANGE_ERROR,
436 THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, false);
441 bool JSSharedArray::SetProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
447 thread, obj, sCheckMode);
448 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false);
450 ObjectOperator op(thread, obj, index);
453 auto error = containers::ContainerError::BusinessError(thread, containers::ErrorFlag::RANGE_ERROR,
455 THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, false);
461 JSTaggedValue JSSharedArray::Sort(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
466 int64_t len = ArrayHelper::GetArrayLength(thread, obj);
468 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
479 ArrayHelper::SortIndexedProperties(thread, obj, len, fn, base::HolesType::SKIP_HOLES);
480 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
489 JSMutableHandle<JSTaggedValue> item(thread, JSTaggedValue::Undefined());
492 JSSharedArray::FastSetPropertyByValue(thread, obj, j, item);
493 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
503 JSTaggedValue::DeletePropertyOrThrow(thread, obj, item);
504 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
511 bool JSSharedArray::IncludeInSortedValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
524 JSHandle<JSTaggedValue> vv = JSSharedArray::FastGetPropertyByValue(thread, obj, middle);
525 ComparisonResult res = JSTaggedValue::Compare(thread, vv, value);
537 void JSSharedArray::CheckAndCopyArray(const JSThread *thread, JSHandle<JSSharedArray> obj)
539 JSHandle<TaggedArray> arr(thread, obj->GetElements());
542 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
546 obj->SetElements(thread, newArray.GetTaggedValue());
548 JSHandle<TaggedArray> prop(thread, obj->GetProperties());
552 obj->SetProperties(thread, newProps.GetTaggedValue());
556 void JSSharedArray::DeleteInElementMode(const JSThread *thread, JSHandle<JSSharedArray> &obj)
558 JSHandle<TaggedArray> elements(thread, obj->GetElements());
570 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
579 newElements->Set(thread, newCurr, value);
582 obj->SetElements(thread, newElements);