mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
!410 modify ACCESSOR for EcmaString and TaggedArray
Merge pull request !410 from changcheng/master
This commit is contained in:
commit
fe5ce5c72f
@ -22,9 +22,9 @@ JSHandle<TaggedArray> BuiltinsBase::GetArgsArray(EcmaRuntimeCallInfo *msg)
|
||||
{
|
||||
JSThread *thread = msg->GetThread();
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
array_size_t length = msg->GetArgsNumber();
|
||||
uint32_t length = msg->GetArgsNumber();
|
||||
JSHandle<TaggedArray> array = factory->NewTaggedArray(length);
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
array->Set(thread, i, GetCallArg(msg, i).GetTaggedValue());
|
||||
}
|
||||
return array;
|
||||
|
@ -31,10 +31,10 @@ JSHandle<JSTaggedValue> Internalize::InternalizeJsonProperty(JSThread *thread, c
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
|
||||
JSTaggedNumber lenNumber = JSTaggedValue::ToLength(thread, lenResult);
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
|
||||
array_size_t length = lenNumber.ToUint32();
|
||||
uint32_t length = lenNumber.ToUint32();
|
||||
JSMutableHandle<JSTaggedValue> keyUnknow(thread, JSTaggedValue::Undefined());
|
||||
JSMutableHandle<JSTaggedValue> keyName(thread, JSTaggedValue::Undefined());
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
// Let prop be ! ToString((I)).
|
||||
keyUnknow.Update(JSTaggedValue(i));
|
||||
keyName.Update(JSTaggedValue::ToString(thread, keyUnknow).GetTaggedValue());
|
||||
@ -44,9 +44,9 @@ JSHandle<JSTaggedValue> Internalize::InternalizeJsonProperty(JSThread *thread, c
|
||||
// Let keys be ? EnumerableOwnPropertyNames(val, key).
|
||||
JSHandle<TaggedArray> ownerNames(JSObject::EnumerableOwnNames(thread, obj));
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
|
||||
array_size_t namesLength = ownerNames->GetLength();
|
||||
uint32_t namesLength = ownerNames->GetLength();
|
||||
JSMutableHandle<JSTaggedValue> keyName(thread, JSTaggedValue::Undefined());
|
||||
for (array_size_t i = 0; i < namesLength; i++) {
|
||||
for (uint32_t i = 0; i < namesLength; i++) {
|
||||
keyName.Update(JSTaggedValue::GetProperty(thread, JSHandle<JSTaggedValue>(ownerNames), i)
|
||||
.GetValue().GetTaggedValue());
|
||||
RecurseAndApply(thread, obj, keyName, receiver);
|
||||
|
@ -165,7 +165,7 @@ JSHandle<JSTaggedValue> JsonStringifier::Stringify(const JSHandle<JSTaggedValue>
|
||||
if (len > 0) {
|
||||
JSMutableHandle<JSTaggedValue> propHandle(thread_, JSTaggedValue::Undefined());
|
||||
// Repeat while k<len.
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
// a. Let v be Get(replacer, ToString(k)).
|
||||
JSTaggedValue prop = FastRuntimeStub::FastGetPropertyByIndex(thread_, replacer.GetTaggedValue(), i);
|
||||
// b. ReturnIfAbrupt(v).
|
||||
@ -237,8 +237,8 @@ JSHandle<JSTaggedValue> JsonStringifier::Stringify(const JSHandle<JSTaggedValue>
|
||||
|
||||
void JsonStringifier::AddDeduplicateProp(const JSHandle<JSTaggedValue> &property)
|
||||
{
|
||||
array_size_t propLen = propList_.size();
|
||||
for (array_size_t i = 0; i < propLen; i++) {
|
||||
uint32_t propLen = propList_.size();
|
||||
for (uint32_t i = 0; i < propLen; i++) {
|
||||
if (JSTaggedValue::SameValue(propList_[i], property)) {
|
||||
return;
|
||||
}
|
||||
@ -414,9 +414,9 @@ void JsonStringifier::SerializeObjectKey(const JSHandle<JSTaggedValue> &key, boo
|
||||
|
||||
bool JsonStringifier::PushValue(const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
array_size_t thisLen = stack_.size();
|
||||
uint32_t thisLen = stack_.size();
|
||||
|
||||
for (array_size_t i = 0; i < thisLen; i++) {
|
||||
for (uint32_t i = 0; i < thisLen; i++) {
|
||||
bool equal = JSTaggedValue::SameValue(stack_[i].GetTaggedValue(), value.GetTaggedValue());
|
||||
if (equal) {
|
||||
return true;
|
||||
@ -458,8 +458,8 @@ bool JsonStringifier::SerializeJSONObject(const JSHandle<JSTaggedValue> &value,
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread_, false);
|
||||
}
|
||||
} else {
|
||||
array_size_t propLen = propList_.size();
|
||||
for (array_size_t i = 0; i < propLen; i++) {
|
||||
uint32_t propLen = propList_.size();
|
||||
for (uint32_t i = 0; i < propLen; i++) {
|
||||
JSTaggedValue tagVal =
|
||||
FastRuntimeStub::FastGetPropertyByValue(thread_, obj.GetTaggedValue(), propList_[i].GetTaggedValue());
|
||||
handleValue_.Update(tagVal);
|
||||
@ -511,7 +511,7 @@ bool JsonStringifier::SerializeJSProxy(const JSHandle<JSTaggedValue> &object, co
|
||||
JSTaggedNumber lenNumber = JSTaggedValue::ToLength(thread_, lenghHandle);
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread_, false);
|
||||
uint32_t length = lenNumber.ToUint32();
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
handleKey_.Update(JSTaggedValue(i));
|
||||
JSHandle<JSTaggedValue> valHandle = JSProxy::GetProperty(thread_, proxy, handleKey_).GetValue();
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread_, false);
|
||||
@ -559,7 +559,7 @@ bool JsonStringifier::SerializeJSArray(const JSHandle<JSTaggedValue> &value, con
|
||||
JSHandle<JSArray> jsArr(value);
|
||||
uint32_t len = jsArr->GetArrayLength();
|
||||
if (len > 0) {
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
JSTaggedValue tagVal = FastRuntimeStub::FastGetPropertyByIndex(thread_, value.GetTaggedValue(), i);
|
||||
if (UNLIKELY(tagVal.IsAccessor())) {
|
||||
tagVal = JSObject::CallGetter(thread_, AccessorData::Cast(tagVal.GetTaggedObject()), value);
|
||||
|
@ -49,7 +49,7 @@ JSTaggedValue BuiltinsArray::ArrayConstructor(EcmaRuntimeCallInfo *argv)
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
|
||||
// 1. Let numberOfArgs be the number of arguments passed to this function call.
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
|
||||
// 3. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
|
||||
JSHandle<JSTaggedValue> constructor = GetConstructor(argv);
|
||||
@ -328,7 +328,7 @@ JSTaggedValue BuiltinsArray::Of(EcmaRuntimeCallInfo *argv)
|
||||
JSHandle<JSTaggedValue> lengthKey = globalConst->GetHandledLengthString();
|
||||
|
||||
// 1. Let len be the actual number of arguments passed to this function.
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
|
||||
// 3. Let C be the this value.
|
||||
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
|
||||
@ -391,7 +391,7 @@ JSTaggedValue BuiltinsArray::Concat(EcmaRuntimeCallInfo *argv)
|
||||
BUILTINS_API_TRACE(argv->GetThread(), Array, Concat);
|
||||
JSThread *thread = argv->GetThread();
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
|
||||
// 1. Let O be ToObject(this value).
|
||||
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
|
||||
@ -1067,7 +1067,7 @@ JSTaggedValue BuiltinsArray::IndexOf(EcmaRuntimeCallInfo *argv)
|
||||
JSThread *thread = argv->GetThread();
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
|
||||
// 1. Let O be ToObject(this value).
|
||||
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
|
||||
@ -1255,7 +1255,7 @@ JSTaggedValue BuiltinsArray::LastIndexOf(EcmaRuntimeCallInfo *argv)
|
||||
JSThread *thread = argv->GetThread();
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
|
||||
// 1. Let O be ToObject(this value).
|
||||
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
|
||||
@ -1464,7 +1464,7 @@ JSTaggedValue BuiltinsArray::Push(EcmaRuntimeCallInfo *argv)
|
||||
return JSStableArray::Push(JSHandle<JSArray>::Cast(thisHandle), argv);
|
||||
}
|
||||
// 6. Let argCount be the number of elements in items.
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
|
||||
// 1. Let O be ToObject(this value).
|
||||
JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
|
||||
@ -1517,7 +1517,7 @@ JSTaggedValue BuiltinsArray::Reduce(EcmaRuntimeCallInfo *argv)
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
const GlobalEnvConstants *globalConst = thread->GlobalConstants();
|
||||
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
// 1. Let O be ToObject(this value).
|
||||
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
|
||||
JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
|
||||
@ -1618,7 +1618,7 @@ JSTaggedValue BuiltinsArray::ReduceRight(EcmaRuntimeCallInfo *argv)
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
const GlobalEnvConstants *globalConst = thread->GlobalConstants();
|
||||
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
|
||||
// 1. Let O be ToObject(this value).
|
||||
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
|
||||
@ -1969,7 +1969,7 @@ JSTaggedValue BuiltinsArray::Slice(EcmaRuntimeCallInfo *argv)
|
||||
TaggedArray *destElements = *JSObject::GrowElementsCapacity(thread, newArrayHandle, count);
|
||||
TaggedArray *srcElements = TaggedArray::Cast(thisObjHandle->GetElements().GetTaggedObject());
|
||||
|
||||
for (array_size_t idx = 0; idx < count; idx++) {
|
||||
for (uint32_t idx = 0; idx < count; idx++) {
|
||||
destElements->Set(thread, idx, srcElements->Get(k + idx));
|
||||
}
|
||||
|
||||
@ -2156,7 +2156,7 @@ JSTaggedValue BuiltinsArray::Splice(EcmaRuntimeCallInfo *argv)
|
||||
BUILTINS_API_TRACE(argv->GetThread(), Array, Splice);
|
||||
JSThread *thread = argv->GetThread();
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
// 1. Let O be ToObject(this value).
|
||||
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
|
||||
JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
|
||||
@ -2493,7 +2493,7 @@ JSTaggedValue BuiltinsArray::Unshift(EcmaRuntimeCallInfo *argv)
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
|
||||
// 5. Let argCount be the number of actual arguments.
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
|
||||
// 1. Let O be ToObject(this value).
|
||||
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
|
||||
|
@ -122,7 +122,7 @@ JSTaggedValue BuiltinsFunction::FunctionPrototypeBind(EcmaRuntimeCallInfo *argv)
|
||||
}
|
||||
|
||||
JSHandle<JSTaggedValue> thisArg = GetCallArg(argv, 0);
|
||||
array_size_t argsLength = 0;
|
||||
uint32_t argsLength = 0;
|
||||
if (argv->GetArgsNumber() > 1) {
|
||||
argsLength = argv->GetArgsNumber() - 1;
|
||||
}
|
||||
@ -130,7 +130,7 @@ JSTaggedValue BuiltinsFunction::FunctionPrototypeBind(EcmaRuntimeCallInfo *argv)
|
||||
// 3. Let args be a new (possibly empty) List consisting of all of the argument
|
||||
// values provided after thisArg in order.
|
||||
JSHandle<TaggedArray> argsArray = factory->NewTaggedArray(argsLength);
|
||||
for (array_size_t index = 0; index < argsLength; ++index) {
|
||||
for (uint32_t index = 0; index < argsLength; ++index) {
|
||||
argsArray->Set(thread, index, GetCallArg(argv, index + 1));
|
||||
}
|
||||
// 4. Let F be BoundFunctionCreate(Target, thisArg, args).
|
||||
@ -212,7 +212,7 @@ JSTaggedValue BuiltinsFunction::FunctionPrototypeCall(EcmaRuntimeCallInfo *argv)
|
||||
|
||||
JSHandle<JSTaggedValue> func = GetThis(argv);
|
||||
JSHandle<JSTaggedValue> thisArg = GetCallArg(argv, 0);
|
||||
array_size_t argsLength = 0;
|
||||
uint32_t argsLength = 0;
|
||||
if (argv->GetArgsNumber() > 1) {
|
||||
argsLength = argv->GetArgsNumber() - 1;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ JSTaggedValue BuiltinsJson::Parse(EcmaRuntimeCallInfo *argv)
|
||||
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc == 0) {
|
||||
JSHandle<JSObject> syntaxError = factory->GetJSError(base::ErrorType::SYNTAX_ERROR, "arg is empty");
|
||||
THROW_NEW_ERROR_AND_RETURN_VALUE(thread, syntaxError.GetTaggedValue(), JSTaggedValue::Exception());
|
||||
@ -83,7 +83,7 @@ JSTaggedValue BuiltinsJson::Stringify(EcmaRuntimeCallInfo *argv)
|
||||
JSThread *thread = argv->GetThread();
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
JSTaggedValue value = GetCallArg(argv, 0).GetTaggedValue();
|
||||
JSTaggedValue replacer = JSTaggedValue::Undefined();
|
||||
JSTaggedValue gap = JSTaggedValue::Undefined();
|
||||
|
@ -81,7 +81,7 @@ JSTaggedValue BuiltinsObject::Assign(EcmaRuntimeCallInfo *argv)
|
||||
// ii.Let keys be from.[[OwnPropertyKeys]]().
|
||||
// iii.ReturnIfAbrupt(keys).
|
||||
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
|
||||
for (array_size_t i = 1; i < numArgs; i++) {
|
||||
for (uint32_t i = 1; i < numArgs; i++) {
|
||||
JSHandle<JSTaggedValue> source = GetCallArg(argv, i);
|
||||
if (!source->IsNull() && !source->IsUndefined()) {
|
||||
JSHandle<JSObject> from = JSTaggedValue::ToObject(thread, source);
|
||||
@ -99,8 +99,8 @@ JSTaggedValue BuiltinsObject::Assign(EcmaRuntimeCallInfo *argv)
|
||||
// 2.ReturnIfAbrupt(propValue).
|
||||
// 3.Let status be Set(to, nextKey, propValue, true).
|
||||
// 4.ReturnIfAbrupt(status).
|
||||
array_size_t keysLen = keys->GetLength();
|
||||
for (array_size_t j = 0; j < keysLen; j++) {
|
||||
uint32_t keysLen = keys->GetLength();
|
||||
for (uint32_t j = 0; j < keysLen; j++) {
|
||||
PropertyDescriptor desc(thread);
|
||||
key.Update(keys->Get(j));
|
||||
bool success = JSTaggedValue::GetOwnProperty(thread, JSHandle<JSTaggedValue>::Cast(from), key, desc);
|
||||
@ -152,7 +152,7 @@ JSTaggedValue BuiltinsObject::ObjectDefineProperties(JSThread *thread, const JSH
|
||||
|
||||
// 6.Let descriptors be an empty List.
|
||||
// new an empty array and append
|
||||
array_size_t length = handleKeys->GetLength();
|
||||
uint32_t length = handleKeys->GetLength();
|
||||
[[maybe_unused]] JSHandle<TaggedArray> descriptors =
|
||||
factory->NewTaggedArray(2 * length); // 2: 2 means two element list
|
||||
|
||||
@ -166,7 +166,7 @@ JSTaggedValue BuiltinsObject::ObjectDefineProperties(JSThread *thread, const JSH
|
||||
// iv.ReturnIfAbrupt(desc).
|
||||
// v.Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
|
||||
JSMutableHandle<JSTaggedValue> handleKey(thread, JSTaggedValue::Undefined());
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
PropertyDescriptor propDesc(thread);
|
||||
handleKey.Update(handleKeys->Get(i));
|
||||
|
||||
@ -364,14 +364,14 @@ JSTaggedValue BuiltinsObject::GetOwnPropertyKeys(JSThread *thread, const JSHandl
|
||||
|
||||
// 5.Let nameList be a new empty List.
|
||||
// new an empty array and append
|
||||
array_size_t length = handleKeys->GetLength();
|
||||
uint32_t length = handleKeys->GetLength();
|
||||
JSHandle<TaggedArray> nameList = factory->NewTaggedArray(length);
|
||||
|
||||
// 6.Repeat for each element nextKey of keys in List order,
|
||||
array_size_t copyLength = 0;
|
||||
uint32_t copyLength = 0;
|
||||
switch (type) {
|
||||
case KeyType::STRING_TYPE: {
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
JSTaggedValue key = handleKeys->Get(i);
|
||||
if (key.IsString()) {
|
||||
nameList->Set(thread, copyLength, key);
|
||||
@ -381,7 +381,7 @@ JSTaggedValue BuiltinsObject::GetOwnPropertyKeys(JSThread *thread, const JSHandl
|
||||
break;
|
||||
}
|
||||
case KeyType::SYMBOL_TYPE: {
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
JSTaggedValue key = handleKeys->Get(i);
|
||||
if (key.IsSymbol()) {
|
||||
nameList->Set(thread, copyLength, key);
|
||||
|
@ -451,7 +451,7 @@ JSHandle<CompletionRecord> BuiltinsPromise::PerformPromiseAll(JSThread *thread,
|
||||
JSHandle<PromiseRecord> remainCnt = factory->NewPromiseRecord();
|
||||
remainCnt->SetValue(thread, JSTaggedNumber(1));
|
||||
// 5. Let index be 0.
|
||||
array_size_t index = 0;
|
||||
uint32_t index = 0;
|
||||
// 6. Repeat
|
||||
JSHandle<JSTaggedValue> itor(thread, itRecord->GetIterator());
|
||||
JSMutableHandle<JSTaggedValue> next(thread, globalConst->GetUndefined());
|
||||
|
@ -268,7 +268,7 @@ JSTaggedValue BuiltinsTypedArray::Of(EcmaRuntimeCallInfo *argv)
|
||||
JSThread *thread = argv->GetThread();
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
// 1. Let len be the actual number of arguments passed to this function.
|
||||
array_size_t len = argv->GetArgsNumber();
|
||||
uint32_t len = argv->GetArgsNumber();
|
||||
// 2. Let items be the List of arguments passed to this function.
|
||||
// 3. Let C be the this value.
|
||||
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
|
||||
static JSTaggedValue TestEveryFunc(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
if (GetCallArg(argv, 0)->GetInt() > 10) { // 10 : test case
|
||||
return GetTaggedBoolean(true);
|
||||
@ -99,7 +99,7 @@ public:
|
||||
|
||||
static JSTaggedValue TestFindFunc(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
// 10 : test case
|
||||
if (GetCallArg(argv, 0)->GetInt() > 10) {
|
||||
@ -111,7 +111,7 @@ public:
|
||||
|
||||
static JSTaggedValue TestFindIndexFunc(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
// 10 : test case
|
||||
if (GetCallArg(argv, 0)->GetInt() > 10) {
|
||||
@ -137,7 +137,7 @@ public:
|
||||
|
||||
static JSTaggedValue TestSomeFunc(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
if (GetCallArg(argv, 0)->GetInt() > 10) { // 10 : test case
|
||||
return GetTaggedBoolean(true);
|
||||
|
@ -68,7 +68,7 @@ JSTaggedValue TestFunctionApplyAndCall(EcmaRuntimeCallInfo *argv)
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
|
||||
int result = 0;
|
||||
for (array_size_t index = 0; index < argv->GetArgsNumber(); ++index) {
|
||||
for (uint32_t index = 0; index < argv->GetArgsNumber(); ++index) {
|
||||
result += BuiltinsBase::GetCallArg(argv, index)->GetInt();
|
||||
}
|
||||
JSHandle<JSTaggedValue> thisValue(BuiltinsBase::GetThis(argv));
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
public:
|
||||
static JSTaggedValue TestForParse(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
}
|
||||
JSTaggedValue key = GetCallArg(argv, 0).GetTaggedValue();
|
||||
@ -87,7 +87,7 @@ public:
|
||||
|
||||
static JSTaggedValue TestForParse1(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
}
|
||||
return JSTaggedValue::Undefined();
|
||||
@ -95,7 +95,7 @@ public:
|
||||
|
||||
static JSTaggedValue TestForStringfy(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
JSTaggedValue key = GetCallArg(argv, 0).GetTaggedValue();
|
||||
if (key.IsUndefined()) {
|
||||
|
@ -120,7 +120,7 @@ HWTEST_F_L0(BuiltinsProxyTest, Revocable)
|
||||
JSHandle<TaggedArray> keys = JSObject::GetOwnPropertyKeys(thread, resultHandle);
|
||||
bool pflag = false;
|
||||
bool rflag = false;
|
||||
for (array_size_t i = 0; i < keys->GetLength(); i++) {
|
||||
for (uint32_t i = 0; i < keys->GetLength(); i++) {
|
||||
if (JSTaggedValue::SameValue(keys->Get(i), proxyKey.GetTaggedValue())) {
|
||||
pflag = true;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ JSTaggedValue TestReflectApply(EcmaRuntimeCallInfo *argv)
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
|
||||
int result = 0;
|
||||
for (array_size_t index = 0; index < argv->GetArgsNumber(); ++index) {
|
||||
for (uint32_t index = 0; index < argv->GetArgsNumber(); ++index) {
|
||||
result += BuiltinsBase::GetCallArg(argv, index).GetTaggedValue().GetInt();
|
||||
}
|
||||
JSHandle<JSTaggedValue> thisValue = BuiltinsBase::GetThis(argv);
|
||||
|
@ -90,7 +90,7 @@ protected:
|
||||
|
||||
static JSTaggedValue TestEveryFunc(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
[[maybe_unused]] int aaa = GetCallArg(argv, 0)->GetInt();
|
||||
// 10 : test case
|
||||
@ -104,7 +104,7 @@ protected:
|
||||
static JSTaggedValue TestFilterFunc(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
ASSERT(argv);
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
// 10 : test case
|
||||
if (GetCallArg(argv, 0)->GetInt() > 10) {
|
||||
@ -123,7 +123,7 @@ protected:
|
||||
|
||||
static JSTaggedValue TestFindFunc(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
// 10 : test case
|
||||
if (GetCallArg(argv, 0)->GetInt() > 10) {
|
||||
@ -135,7 +135,7 @@ protected:
|
||||
|
||||
static JSTaggedValue TestFindIndexFunc(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
// 10 : test case
|
||||
if (GetCallArg(argv, 0)->GetInt() > 10) {
|
||||
@ -161,7 +161,7 @@ protected:
|
||||
|
||||
static JSTaggedValue TestSomeFunc(EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
if (argc > 0) {
|
||||
// 10 : test case
|
||||
if (GetCallArg(argv, 0)->GetInt() > 10) {
|
||||
|
@ -237,7 +237,7 @@ Program *PandaFileTranslator::GenerateProgram(const panda_file::File &pf)
|
||||
size_t index = it.first;
|
||||
JSHandle<TaggedArray> literal =
|
||||
LiteralDataExtractor::GetDatasIgnoreType(thread_, &pf, static_cast<size_t>(index));
|
||||
array_size_t length = literal->GetLength();
|
||||
uint32_t length = literal->GetLength();
|
||||
|
||||
JSHandle<JSArray> arr(JSArray::ArrayCreate(thread_, JSTaggedNumber(length)));
|
||||
arr->SetElements(thread_, literal);
|
||||
@ -580,8 +580,8 @@ JSHandle<JSFunction> PandaFileTranslator::DefineMethodInLiteral(JSThread *thread
|
||||
|
||||
void PandaFileTranslator::DefineClassInConstPool(const JSHandle<ConstantPool> &constpool) const
|
||||
{
|
||||
array_size_t length = constpool->GetLength();
|
||||
array_size_t index = 0;
|
||||
uint32_t length = constpool->GetLength();
|
||||
uint32_t index = 0;
|
||||
while (index < length - 1) {
|
||||
JSTaggedValue value = constpool->Get(index);
|
||||
if (!value.IsClassInfoExtractor()) {
|
||||
|
@ -862,7 +862,7 @@ void Stub::SetPropertiesArray(GateRef glue, GateRef object, GateRef propsArray)
|
||||
|
||||
GateRef Stub::GetLengthofTaggedArray(GateRef array)
|
||||
{
|
||||
return Load(MachineType::UINT32, array, GetArchRelateConstant(TaggedArray::GetLengthOffset()));
|
||||
return Load(MachineType::UINT32, array, GetArchRelateConstant(TaggedArray::LENGTH_OFFSET));
|
||||
}
|
||||
|
||||
GateRef Stub::IsJSHClass(GateRef obj)
|
||||
@ -1348,7 +1348,7 @@ void Stub::SetValueToTaggedArray(MachineType valType, GateRef glue, GateRef arra
|
||||
// NOTE: need to translate MarkingBarrier
|
||||
GateRef offset =
|
||||
ArchRelatePtrMul(ChangeInt32ToUintPtr(index), GetArchRelateConstant(JSTaggedValue::TaggedTypeSize()));
|
||||
GateRef dataOffset = PtrAdd(offset, GetArchRelateConstant(TaggedArray::GetDataOffset()));
|
||||
GateRef dataOffset = PtrAdd(offset, GetArchRelateConstant(TaggedArray::DATA_OFFSET));
|
||||
Store(valType, glue, array, dataOffset, val);
|
||||
}
|
||||
|
||||
@ -1356,7 +1356,7 @@ GateRef Stub::GetValueFromTaggedArray(MachineType returnType, GateRef array, Gat
|
||||
{
|
||||
GateRef offset =
|
||||
ArchRelatePtrMul(ChangeInt32ToUintPtr(index), GetArchRelateConstant(JSTaggedValue::TaggedTypeSize()));
|
||||
GateRef dataOffset = PtrAdd(offset, GetArchRelateConstant(TaggedArray::GetDataOffset()));
|
||||
GateRef dataOffset = PtrAdd(offset, GetArchRelateConstant(TaggedArray::DATA_OFFSET));
|
||||
return Load(returnType, array, dataOffset);
|
||||
}
|
||||
|
||||
@ -1372,7 +1372,7 @@ void Stub::UpdateValueAndAttributes(GateRef glue, GateRef elements, GateRef inde
|
||||
SetValueToTaggedArray(MachineType::TAGGED, glue, elements, valueIndex, value);
|
||||
GateRef attroffset =
|
||||
ArchRelatePtrMul(ChangeInt32ToUintPtr(attributesIndex), GetArchRelateConstant(JSTaggedValue::TaggedTypeSize()));
|
||||
GateRef dataOffset = PtrAdd(attroffset, GetArchRelateConstant(TaggedArray::GetDataOffset()));
|
||||
GateRef dataOffset = PtrAdd(attroffset, GetArchRelateConstant(TaggedArray::DATA_OFFSET));
|
||||
Store(MachineType::INT64, glue, elements, dataOffset, IntBuildTaggedWithNoGC(attr));
|
||||
}
|
||||
|
||||
@ -1429,7 +1429,7 @@ GateRef Stub::GetKeyFromDictionary(MachineType returnType, GateRef elements, Gat
|
||||
Label gtLength(env);
|
||||
Label notGtLength(env);
|
||||
GateRef dictionaryLength =
|
||||
Load(MachineType::INT32, elements, GetArchRelateConstant(panda::coretypes::Array::GetLengthOffset()));
|
||||
Load(MachineType::INT32, elements, GetArchRelateConstant(TaggedArray::LENGTH_OFFSET));
|
||||
GateRef arrayIndex =
|
||||
Int32Add(GetInt32Constant(DictionaryT::TABLE_HEADER_SIZE),
|
||||
Int32Mul(entry, GetInt32Constant(DictionaryT::ENTRY_SIZE)));
|
||||
@ -1474,7 +1474,7 @@ GateRef Stub::GetPropertiesAddrFromLayoutInfo(GateRef layout)
|
||||
{
|
||||
GateRef eleStartIdx = ArchRelatePtrMul(GetArchRelateConstant(LayoutInfo::ELEMENTS_START_INDEX),
|
||||
GetArchRelateConstant(JSTaggedValue::TaggedTypeSize()));
|
||||
return PtrAdd(layout, PtrAdd(GetArchRelateConstant(TaggedArray::GetDataOffset()), eleStartIdx));
|
||||
return PtrAdd(layout, PtrAdd(GetArchRelateConstant(TaggedArray::DATA_OFFSET), eleStartIdx));
|
||||
}
|
||||
|
||||
GateRef Stub::TaggedCastToInt64(GateRef x)
|
||||
|
@ -440,7 +440,7 @@ GateRef Stub::FindElementFromNumberDictionary(GateRef glue, GateRef elements, Ga
|
||||
GateRef capcityoffset =
|
||||
ArchRelatePtrMul(GetArchRelateConstant(JSTaggedValue::TaggedTypeSize()),
|
||||
GetArchRelateConstant(TaggedHashTable<NumberDictionary>::SIZE_INDEX));
|
||||
GateRef dataoffset = GetArchRelateConstant(TaggedArray::GetDataOffset());
|
||||
GateRef dataoffset = GetArchRelateConstant(TaggedArray::DATA_OFFSET);
|
||||
GateRef capacity = TaggedCastToInt32(Load(MachineType::UINT64, elements, ArchRelateAdd(dataoffset, capcityoffset)));
|
||||
DEFVARIABLE(count, MachineType::INT32, GetInt32Constant(1));
|
||||
|
||||
@ -538,7 +538,7 @@ GateRef Stub::FindEntryFromNameDictionary(GateRef glue, GateRef elements, GateRe
|
||||
GateRef capcityoffset =
|
||||
ArchRelatePtrMul(GetArchRelateConstant(JSTaggedValue::TaggedTypeSize()),
|
||||
GetArchRelateConstant(TaggedHashTable<NumberDictionary>::SIZE_INDEX));
|
||||
GateRef dataoffset = GetArchRelateConstant(TaggedArray::GetDataOffset());
|
||||
GateRef dataoffset = GetArchRelateConstant(TaggedArray::DATA_OFFSET);
|
||||
GateRef capacity = TaggedCastToInt32(Load(MachineType::UINT64, elements, PtrAdd(dataoffset, capcityoffset)));
|
||||
DEFVARIABLE(count, MachineType::INT32, GetInt32Constant(1));
|
||||
DEFVARIABLE(hash, MachineType::INT32, GetInt32Constant(0));
|
||||
@ -648,7 +648,7 @@ GateRef Stub::FindEntryFromTransitionDictionary(GateRef glue, GateRef elements,
|
||||
GateRef capcityoffset =
|
||||
ArchRelatePtrMul(GetArchRelateConstant(JSTaggedValue::TaggedTypeSize()),
|
||||
GetArchRelateConstant(TaggedHashTable<NumberDictionary>::SIZE_INDEX));
|
||||
GateRef dataoffset = GetArchRelateConstant(TaggedArray::GetDataOffset());
|
||||
GateRef dataoffset = GetArchRelateConstant(TaggedArray::DATA_OFFSET);
|
||||
GateRef capacity = TaggedCastToInt32(Load(MachineType::UINT64, elements, PtrAdd(dataoffset, capcityoffset)));
|
||||
DEFVARIABLE(count, MachineType::INT32, GetInt32Constant(1));
|
||||
DEFVARIABLE(hash, MachineType::INT32, GetInt32Constant(0));
|
||||
@ -1242,7 +1242,7 @@ GateRef Stub::TaggedIsStringOrSymbol(GateRef obj)
|
||||
GateRef Stub::IsUtf16String(GateRef string)
|
||||
{
|
||||
// compressedStringsEnabled fixed to true constant
|
||||
GateRef len = Load(MachineType::UINT32, string, GetArchRelateConstant(EcmaString::GetLengthOffset()));
|
||||
GateRef len = Load(MachineType::UINT32, string, GetArchRelateConstant(EcmaString::MIX_LENGTH_OFFSET));
|
||||
return Word32Equal(
|
||||
Word32And(len, GetInt32Constant(EcmaString::STRING_COMPRESSED_BIT)),
|
||||
GetInt32Constant(EcmaString::STRING_UNCOMPRESSED));
|
||||
@ -1251,7 +1251,7 @@ GateRef Stub::IsUtf16String(GateRef string)
|
||||
GateRef Stub::IsUtf8String(GateRef string)
|
||||
{
|
||||
// compressedStringsEnabled fixed to true constant
|
||||
GateRef len = Load(MachineType::UINT32, string, GetArchRelateConstant(EcmaString::GetLengthOffset()));
|
||||
GateRef len = Load(MachineType::UINT32, string, GetArchRelateConstant(EcmaString::MIX_LENGTH_OFFSET));
|
||||
return Word32Equal(
|
||||
Word32And(len, GetInt32Constant(EcmaString::STRING_COMPRESSED_BIT)),
|
||||
GetInt32Constant(EcmaString::STRING_COMPRESSED));
|
||||
@ -1260,7 +1260,7 @@ GateRef Stub::IsUtf8String(GateRef string)
|
||||
GateRef Stub::IsInternalString(GateRef string)
|
||||
{
|
||||
// compressedStringsEnabled fixed to true constant
|
||||
GateRef len = Load(MachineType::UINT32, string, GetArchRelateConstant(EcmaString::GetLengthOffset()));
|
||||
GateRef len = Load(MachineType::UINT32, string, GetArchRelateConstant(EcmaString::MIX_LENGTH_OFFSET));
|
||||
return Word32NotEqual(
|
||||
Word32And(len, GetInt32Constant(EcmaString::STRING_INTERN_BIT)),
|
||||
GetInt32Constant(0));
|
||||
@ -1282,14 +1282,14 @@ GateRef Stub::StringToElementIndex(GateRef string)
|
||||
DEFVARIABLE(result, MachineType::INT32, GetInt32Constant(-1));
|
||||
Label greatThanZero(env);
|
||||
Label inRange(env);
|
||||
GateRef len = Load(MachineType::UINT32, string, GetArchRelateConstant(EcmaString::GetLengthOffset()));
|
||||
GateRef len = Load(MachineType::UINT32, string, GetArchRelateConstant(EcmaString::MIX_LENGTH_OFFSET));
|
||||
len = Word32LSR(len, GetInt32Constant(2)); // 2 : 2 means len must be right shift 2 bits
|
||||
Branch(Word32Equal(len, GetInt32Constant(0)), &exit, &greatThanZero);
|
||||
Bind(&greatThanZero);
|
||||
Branch(Int32GreaterThan(len, GetInt32Constant(MAX_INDEX_LEN)), &exit, &inRange);
|
||||
Bind(&inRange);
|
||||
{
|
||||
GateRef dataUtf16 = PtrAdd(string, GetArchRelateConstant(EcmaString::GetDataOffset()));
|
||||
GateRef dataUtf16 = PtrAdd(string, GetArchRelateConstant(EcmaString::DATA_OFFSET));
|
||||
DEFVARIABLE(c, MachineType::UINT32, GetInt32Constant(0));
|
||||
Label isUtf16(env);
|
||||
Label isUtf8(env);
|
||||
@ -1865,7 +1865,7 @@ void Stub::StoreWithTransition(GateRef glue, GateRef receiver, GateRef value, Ga
|
||||
}
|
||||
Bind(&indexLessCapacity);
|
||||
{
|
||||
Store(MachineType::UINT64, glue, ArchRelateAdd(array, GetArchRelateConstant(TaggedArray::GetDataOffset())),
|
||||
Store(MachineType::UINT64, glue, ArchRelateAdd(array, GetArchRelateConstant(TaggedArray::DATA_OFFSET)),
|
||||
ArchRelatePtrMul(ChangeInt32ToUintPtr(index), GetArchRelateConstant(JSTaggedValue::TaggedTypeSize())),
|
||||
value);
|
||||
Jump(&exit);
|
||||
|
@ -267,9 +267,9 @@ CString JSHClass::DumpJSType(JSType type)
|
||||
static void DumpArrayClass(JSThread *thread, const TaggedArray *arr, std::ostream &os)
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
array_size_t len = arr->GetLength();
|
||||
uint32_t len = arr->GetLength();
|
||||
os << " <TaggedArray[" << std::dec << len << "]>\n";
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
JSTaggedValue val(arr->Get(i));
|
||||
if (!val.IsHole()) {
|
||||
os << std::right << std::setw(DUMP_PROPERTY_OFFSET) << i << ": ";
|
||||
@ -1943,8 +1943,8 @@ static void DumpArrayClass([[maybe_unused]] JSThread *thread, const TaggedArray
|
||||
std::vector<std::pair<CString, JSTaggedValue>> &vec)
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
array_size_t len = arr->GetLength();
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
uint32_t len = arr->GetLength();
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
JSTaggedValue val(arr->Get(i));
|
||||
CString str = ToCString(i);
|
||||
vec.push_back(std::make_pair(str, val));
|
||||
|
@ -60,7 +60,7 @@
|
||||
/* dynamically-typed languages like JavaScript. So we simply skip the read-barrier. */ \
|
||||
return JSTaggedValue(Barriers::GetDynValue<JSTaggedType>(this, offset)); \
|
||||
} \
|
||||
template<typename T> \
|
||||
template<typename T> \
|
||||
void Set##name(const JSThread *thread, JSHandle<T> value, BarrierMode mode = WRITE_BARRIER) \
|
||||
{ \
|
||||
if (mode == WRITE_BARRIER) { \
|
||||
@ -87,7 +87,7 @@
|
||||
} \
|
||||
void Set##name(JSTaggedValue value) \
|
||||
{ \
|
||||
Barriers::SetDynPrimitive<JSTaggedType>(this, offset, value.GetRawData()); \
|
||||
Barriers::SetDynPrimitive<JSTaggedType>(this, offset, value.GetRawData()); \
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
@ -235,19 +235,19 @@
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define DATE_STRING(name) \
|
||||
static JSTaggedValue name(EcmaRuntimeCallInfo *argv) \
|
||||
{ \
|
||||
ASSERT(argv); \
|
||||
JSThread *thread = argv->GetThread(); \
|
||||
JSHandle<JSTaggedValue> msg = GetThis(argv); \
|
||||
if (!msg->IsDate()) { \
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Not a Date Object", JSTaggedValue::Exception()); \
|
||||
} \
|
||||
if (std::isnan(JSDate::Cast(msg->GetTaggedObject())->GetTimeValue().GetDouble())) { \
|
||||
#define DATE_STRING(name) \
|
||||
static JSTaggedValue name(EcmaRuntimeCallInfo *argv) \
|
||||
{ \
|
||||
ASSERT(argv); \
|
||||
JSThread *thread = argv->GetThread(); \
|
||||
JSHandle<JSTaggedValue> msg = GetThis(argv); \
|
||||
if (!msg->IsDate()) { \
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Not a Date Object", JSTaggedValue::Exception()); \
|
||||
} \
|
||||
if (std::isnan(JSDate::Cast(msg->GetTaggedObject())->GetTimeValue().GetDouble())) { \
|
||||
return thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Invalid Date").GetTaggedValue(); \
|
||||
} \
|
||||
return JSDate::Cast(msg->GetTaggedObject())->name(thread); \
|
||||
} \
|
||||
return JSDate::Cast(msg->GetTaggedObject())->name(thread); \
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
@ -350,13 +350,13 @@
|
||||
} while (false)
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define RETURN_COMPLETION_IF_ABRUPT(thread, value) \
|
||||
do { \
|
||||
if (thread->HasPendingException()) { \
|
||||
JSHandle<CompletionRecord> completionRecord = \
|
||||
factory->NewCompletionRecord(CompletionRecord::THROW, value); \
|
||||
return (completionRecord); \
|
||||
} \
|
||||
#define RETURN_COMPLETION_IF_ABRUPT(thread, value) \
|
||||
do { \
|
||||
if (thread->HasPendingException()) { \
|
||||
JSHandle<CompletionRecord> completionRecord = \
|
||||
factory->NewCompletionRecord(CompletionRecord::THROW, value); \
|
||||
return (completionRecord); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
@ -379,30 +379,38 @@
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define DECL_VISIT_OBJECT(BEGIN_OFFSET, SIZE) \
|
||||
void VisitRangeSlot(const EcmaObjectRangeVisitor &visitor) \
|
||||
{ \
|
||||
visitor(this, ObjectSlot(ToUintPtr(this) + BEGIN_OFFSET), ObjectSlot(ToUintPtr(this) + SIZE)); \
|
||||
#define DECL_VISIT_ARRAY(BEGIN_OFFSET, LENGTH) \
|
||||
void VisitRangeSlot(const EcmaObjectRangeVisitor &visitor) \
|
||||
{ \
|
||||
size_t endOffset = (BEGIN_OFFSET) + (LENGTH) * JSTaggedValue::TaggedTypeSize(); \
|
||||
visitor(this, ObjectSlot(ToUintPtr(this) + (BEGIN_OFFSET)), ObjectSlot(ToUintPtr(this) + endOffset)); \
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define DECL_VISIT_OBJECT_FOR_JS_OBJECT(PARENTCLASS, BEGIN_OFFSET, SIZE) \
|
||||
void VisitRangeSlot(const EcmaObjectRangeVisitor &visitor) \
|
||||
{ \
|
||||
VisitObjects(visitor); \
|
||||
/* visit in object fields */ \
|
||||
auto objSize = this->GetClass()->GetObjectSize(); \
|
||||
if (objSize > SIZE) { \
|
||||
visitor(this, ObjectSlot(ToUintPtr(this) + SIZE), ObjectSlot(ToUintPtr(this) + objSize)); \
|
||||
} \
|
||||
} \
|
||||
void VisitObjects(const EcmaObjectRangeVisitor &visitor) \
|
||||
{ \
|
||||
PARENTCLASS::VisitObjects(visitor); \
|
||||
if (BEGIN_OFFSET == SIZE) { \
|
||||
return; \
|
||||
} \
|
||||
visitor(this, ObjectSlot(ToUintPtr(this) + BEGIN_OFFSET), ObjectSlot(ToUintPtr(this) + SIZE)); \
|
||||
#define DECL_VISIT_OBJECT(BEGIN_OFFSET, END_OFFSET) \
|
||||
void VisitRangeSlot(const EcmaObjectRangeVisitor &visitor) \
|
||||
{ \
|
||||
visitor(this, ObjectSlot(ToUintPtr(this) + (BEGIN_OFFSET)), ObjectSlot(ToUintPtr(this) + (END_OFFSET))); \
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define DECL_VISIT_OBJECT_FOR_JS_OBJECT(PARENTCLASS, BEGIN_OFFSET, END_OFFSET) \
|
||||
void VisitRangeSlot(const EcmaObjectRangeVisitor &visitor) \
|
||||
{ \
|
||||
VisitObjects(visitor); \
|
||||
/* visit in object fields */ \
|
||||
auto objSize = this->GetClass()->GetObjectSize(); \
|
||||
if (objSize > (END_OFFSET)) { \
|
||||
visitor(this, ObjectSlot(ToUintPtr(this) + (END_OFFSET)), ObjectSlot(ToUintPtr(this) + objSize)); \
|
||||
} \
|
||||
} \
|
||||
void VisitObjects(const EcmaObjectRangeVisitor &visitor) \
|
||||
{ \
|
||||
PARENTCLASS::VisitObjects(visitor); \
|
||||
if ((BEGIN_OFFSET) == (END_OFFSET)) { \
|
||||
return; \
|
||||
} \
|
||||
visitor(this, ObjectSlot(ToUintPtr(this) + (BEGIN_OFFSET)), ObjectSlot(ToUintPtr(this) + (END_OFFSET))); \
|
||||
}
|
||||
|
||||
#if ECMASCRIPT_ENABLE_CAST_CHECK
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
* The number of arguments pairs excluding the 'func', 'new.target' and 'this'. For instance:
|
||||
* for code fragment: " foo(v1); ", GetArgsNumber() returns 1
|
||||
*/
|
||||
inline array_size_t GetArgsNumber() const
|
||||
inline uint32_t GetArgsNumber() const
|
||||
{
|
||||
return numArgs_ - NUM_MANDATORY_JSFUNC_ARGS;
|
||||
}
|
||||
|
@ -40,9 +40,9 @@ inline const EcmaString *EcmaString::ConstCast(const TaggedObject *object)
|
||||
/* static */
|
||||
inline EcmaString *EcmaString::CreateEmptyString(const EcmaVM *vm)
|
||||
{
|
||||
auto string = vm->GetFactory()->AllocNonMovableStringObject(sizeof(EcmaString));
|
||||
auto string = vm->GetFactory()->AllocNonMovableStringObject(EcmaString::SIZE);
|
||||
string->SetLength(0, GetCompressedStringsEnabled());
|
||||
string->SetHashcode(0);
|
||||
string->SetRawHashcode(0);
|
||||
return string;
|
||||
}
|
||||
|
||||
@ -120,9 +120,10 @@ inline EcmaString *EcmaString::AllocStringObject(size_t length, bool compressed,
|
||||
size_t size = compressed ? ComputeSizeUtf8(length) : ComputeSizeUtf16(length);
|
||||
auto string = reinterpret_cast<EcmaString *>(vm->GetFactory()->AllocStringObject(size));
|
||||
string->SetLength(length, compressed);
|
||||
string->SetHashcode(0);
|
||||
string->SetRawHashcode(0);
|
||||
return reinterpret_cast<EcmaString *>(string);
|
||||
}
|
||||
|
||||
void EcmaString::WriteData(EcmaString *src, uint32_t start, uint32_t destSize, uint32_t length)
|
||||
{
|
||||
if (IsUtf8()) {
|
||||
@ -147,6 +148,7 @@ void EcmaString::WriteData(EcmaString *src, uint32_t start, uint32_t destSize, u
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EcmaString::WriteData(char src, uint32_t start)
|
||||
{
|
||||
if (IsUtf8()) {
|
||||
|
@ -59,17 +59,17 @@ public:
|
||||
|
||||
bool IsUtf16() const
|
||||
{
|
||||
return compressedStringsEnabled ? ((length_ & STRING_COMPRESSED_BIT) == STRING_UNCOMPRESSED) : true;
|
||||
return compressedStringsEnabled ? ((GetMixLength() & STRING_COMPRESSED_BIT) == STRING_UNCOMPRESSED) : true;
|
||||
}
|
||||
|
||||
bool IsUtf8() const
|
||||
{
|
||||
return compressedStringsEnabled ? ((length_ & STRING_COMPRESSED_BIT) == STRING_COMPRESSED) : false;
|
||||
return compressedStringsEnabled ? ((GetMixLength() & STRING_COMPRESSED_BIT) == STRING_COMPRESSED) : false;
|
||||
}
|
||||
|
||||
static size_t ComputeDataSizeUtf16(uint32_t length)
|
||||
{
|
||||
return length * sizeof(dataUtf16_[0]);
|
||||
return length * sizeof(uint16_t);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,13 +77,18 @@ public:
|
||||
*/
|
||||
static size_t ComputeSizeUtf16(uint32_t utf16Len)
|
||||
{
|
||||
return sizeof(EcmaString) + ComputeDataSizeUtf16(utf16Len);
|
||||
return DATA_OFFSET + ComputeDataSizeUtf16(utf16Len);
|
||||
}
|
||||
|
||||
inline uint16_t *GetData() const
|
||||
{
|
||||
return reinterpret_cast<uint16_t *>(ToUintPtr(this) + DATA_OFFSET);
|
||||
}
|
||||
|
||||
const uint16_t *GetDataUtf16() const
|
||||
{
|
||||
LOG_IF(!IsUtf16(), FATAL, RUNTIME) << "EcmaString: Read data as utf16 for utf8 string";
|
||||
return dataUtf16_;
|
||||
return GetData();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,7 +96,7 @@ public:
|
||||
*/
|
||||
static size_t ComputeSizeUtf8(uint32_t utf8Len)
|
||||
{
|
||||
return sizeof(EcmaString) + utf8Len;
|
||||
return DATA_OFFSET + utf8Len;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,7 +105,7 @@ public:
|
||||
const uint8_t *GetDataUtf8() const
|
||||
{
|
||||
LOG_IF(IsUtf16(), FATAL, RUNTIME) << "EcmaString: Read data as utf8 for utf16 string";
|
||||
return reinterpret_cast<const uint8_t *>(dataUtf16_);
|
||||
return reinterpret_cast<uint8_t *>(GetData());
|
||||
}
|
||||
|
||||
size_t GetUtf8Length() const
|
||||
@ -108,7 +113,7 @@ public:
|
||||
if (!IsUtf16()) {
|
||||
return GetLength() + 1; // add place for zero in the end
|
||||
}
|
||||
return base::utf_helper::Utf16ToUtf8Size(dataUtf16_, GetLength());
|
||||
return base::utf_helper::Utf16ToUtf8Size(GetData(), GetLength());
|
||||
}
|
||||
|
||||
size_t GetUtf16Length() const
|
||||
@ -188,17 +193,17 @@ public:
|
||||
inline void WriteData(char src, uint32_t start);
|
||||
uint32_t GetLength() const
|
||||
{
|
||||
return length_ >> 2U;
|
||||
return GetMixLength() >> 2U;
|
||||
}
|
||||
|
||||
void SetIsInternString()
|
||||
{
|
||||
length_ |= STRING_INTERN_BIT;
|
||||
SetMixLength(GetMixLength() | STRING_INTERN_BIT);
|
||||
}
|
||||
|
||||
bool IsInternString() const
|
||||
{
|
||||
return (length_ & STRING_INTERN_BIT) != 0;
|
||||
return (GetMixLength() & STRING_INTERN_BIT) != 0;
|
||||
}
|
||||
|
||||
size_t ObjectSize() const
|
||||
@ -209,24 +214,16 @@ public:
|
||||
|
||||
uint32_t GetHashcode()
|
||||
{
|
||||
if (hashcode_ == 0) {
|
||||
hashcode_ = ComputeHashcode();
|
||||
uint32_t hashcode = GetRawHashcode();
|
||||
if (hashcode == 0) {
|
||||
hashcode = ComputeHashcode();
|
||||
SetRawHashcode(hashcode);
|
||||
}
|
||||
return hashcode_;
|
||||
return hashcode;
|
||||
}
|
||||
|
||||
int32_t IndexOf(const EcmaString *rhs, int pos = 0) const;
|
||||
|
||||
static constexpr uint32_t GetLengthOffset()
|
||||
{
|
||||
return MEMBER_OFFSET(EcmaString, length_);
|
||||
}
|
||||
|
||||
static constexpr uint32_t GetDataOffset()
|
||||
{
|
||||
return MEMBER_OFFSET(EcmaString, dataUtf16_);
|
||||
}
|
||||
|
||||
static constexpr uint32_t GetStringCompressionMask()
|
||||
{
|
||||
return STRING_COMPRESSED_BIT;
|
||||
@ -263,29 +260,32 @@ public:
|
||||
static bool CanBeCompressed(const uint8_t *utf8Data);
|
||||
static bool CanBeCompressed(const uint16_t *utf16Data, uint32_t utf16Len);
|
||||
|
||||
static constexpr size_t MIX_LENGTH_OFFSET = TaggedObjectSize();
|
||||
// In last bit of mix_length we store if this string is compressed or not.
|
||||
SET_GET_PRIMITIVE_FIELD(MixLength, uint32_t, MIX_LENGTH_OFFSET, HASHCODE_OFFSET);
|
||||
SET_GET_PRIMITIVE_FIELD(RawHashcode, uint32_t, HASHCODE_OFFSET, DATA_OFFSET);
|
||||
// DATA_OFFSET: the string data stored after the string header.
|
||||
// Data can be stored in utf8 or utf16 form according to compressed bit.
|
||||
static constexpr size_t SIZE = DATA_OFFSET; // Empty String size
|
||||
|
||||
private:
|
||||
void SetLength(uint32_t length, bool compressed = false)
|
||||
{
|
||||
ASSERT(length < 0x40000000U);
|
||||
// Use 0u for compressed/utf8 expression
|
||||
length_ = (length << 2U) | (compressed ? STRING_COMPRESSED : STRING_UNCOMPRESSED);
|
||||
}
|
||||
|
||||
void SetHashcode(uint32_t hashcode)
|
||||
{
|
||||
hashcode_ = hashcode;
|
||||
SetMixLength((length << 2U) | (compressed ? STRING_COMPRESSED : STRING_UNCOMPRESSED));
|
||||
}
|
||||
|
||||
uint16_t *GetDataUtf16Writable()
|
||||
{
|
||||
LOG_IF(!IsUtf16(), FATAL, RUNTIME) << "EcmaString: Read data as utf16 for utf8 string";
|
||||
return dataUtf16_;
|
||||
return GetData();
|
||||
}
|
||||
|
||||
uint8_t *GetDataUtf8Writable()
|
||||
{
|
||||
LOG_IF(IsUtf16(), FATAL, RUNTIME) << "EcmaString: Read data as utf8 for utf16 string";
|
||||
return reinterpret_cast<uint8_t *>(dataUtf16_);
|
||||
return reinterpret_cast<uint8_t *>(GetData());
|
||||
}
|
||||
|
||||
uint32_t ComputeHashcode() const;
|
||||
@ -320,13 +320,6 @@ private:
|
||||
|
||||
template<typename T1, typename T2>
|
||||
static int32_t IndexOf(Span<const T1> &lhsSp, Span<const T2> &rhsSp, int32_t pos, int32_t max);
|
||||
|
||||
// In last bit of length_ we store if this string is compressed or not.
|
||||
uint32_t length_;
|
||||
uint32_t hashcode_;
|
||||
// A pointer to the string data stored after the string header.
|
||||
// Data can be stored in utf8 or utf16 form according to compressed bit.
|
||||
__extension__ uint16_t dataUtf16_[0]; // NOLINT(modernize-avoid-c-arrays)
|
||||
};
|
||||
} // namespace ecmascript
|
||||
} // namespace panda
|
||||
|
@ -461,7 +461,7 @@ Expected<int, Runtime::Error> EcmaVM::InvokeEcmaEntrypoint(const panda_file::Fil
|
||||
JSHandle<JSTaggedValue> global = GlobalEnv::Cast(globalEnv_.GetTaggedObject())->GetJSGlobalObject();
|
||||
JSHandle<JSTaggedValue> newTarget(thread_, JSTaggedValue::Undefined());
|
||||
JSHandle<TaggedArray> jsargs = factory_->NewTaggedArray(args.size());
|
||||
array_size_t i = 0;
|
||||
uint32_t i = 0;
|
||||
for (const std::string &str : args) {
|
||||
JSHandle<JSTaggedValue> strobj(factory_->NewFromStdString(str));
|
||||
jsargs->Set(thread_, i++, strobj);
|
||||
|
@ -119,7 +119,7 @@ void GlobalDictionary::GetAllKeys(const JSThread *thread, int offset, TaggedArra
|
||||
}
|
||||
|
||||
void GlobalDictionary::GetEnumAllKeys(const JSThread *thread, int offset, TaggedArray *keyArray,
|
||||
array_size_t *keys) const
|
||||
uint32_t *keys) const
|
||||
{
|
||||
ASSERT_PRINT(offset + EntriesCount() <= static_cast<int>(keyArray->GetLength()),
|
||||
"keyArray capacity is not enough for dictionary");
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
|
||||
inline void GetAllKeys(const JSThread *thread, int offset, TaggedArray *keyArray) const;
|
||||
|
||||
inline void GetEnumAllKeys(const JSThread *thread, int offset, TaggedArray *keyArray, array_size_t *keys) const;
|
||||
inline void GetEnumAllKeys(const JSThread *thread, int offset, TaggedArray *keyArray, uint32_t *keys) const;
|
||||
|
||||
static bool inline CompKey(const std::pair<JSTaggedValue, uint32_t> &a,
|
||||
const std::pair<JSTaggedValue, uint32_t> &b);
|
||||
|
@ -200,12 +200,9 @@ public:
|
||||
static constexpr size_t HEADER_SIZE = TaggedObjectSize();
|
||||
static constexpr size_t SIZE = HEADER_SIZE + FINAL_INDEX * JSTaggedValue::TaggedTypeSize();
|
||||
|
||||
DECL_DUMP()
|
||||
DECL_VISIT_OBJECT(HEADER_SIZE, SIZE);
|
||||
|
||||
inline void VisitRangeSlot(const EcmaObjectRangeVisitor &v)
|
||||
{
|
||||
v(this, ObjectSlot(ToUintPtr(this) + HEADER_SIZE), ObjectSlot(ToUintPtr(this) + SIZE));
|
||||
}
|
||||
DECL_DUMP()
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
|
@ -86,8 +86,8 @@ JSTaggedValue ICRuntimeStub::CheckPolyHClass(JSTaggedValue cachedValue, JSHClass
|
||||
if (!cachedValue.IsWeak()) {
|
||||
ASSERT(cachedValue.IsTaggedArray());
|
||||
TaggedArray *array = TaggedArray::Cast(cachedValue.GetHeapObject());
|
||||
array_size_t length = array->GetLength();
|
||||
for (array_size_t i = 0; i < length; i += 2) { // 2 means one ic, two slot
|
||||
uint32_t length = array->GetLength();
|
||||
for (uint32_t i = 0; i < length; i += 2) { // 2 means one ic, two slot
|
||||
auto result = array->Get(i);
|
||||
if (result != JSTaggedValue::Undefined() && result.GetWeakReferent() == hclass) {
|
||||
return array->Get(i + 1);
|
||||
|
@ -63,8 +63,8 @@ JSTaggedValue InvokeCache::CheckPolyInvokeCache(JSTaggedValue cachedArray, JSTag
|
||||
{
|
||||
ASSERT(cachedArray.IsTaggedArray());
|
||||
TaggedArray *array = TaggedArray::Cast(cachedArray.GetHeapObject());
|
||||
array_size_t length = array->GetLength();
|
||||
for (array_size_t index = 0; index < length; index += 2) { // 2: means one ic, two slot
|
||||
uint32_t length = array->GetLength();
|
||||
for (uint32_t index = 0; index < length; index += 2) { // 2: means one ic, two slot
|
||||
auto result = array->Get(index);
|
||||
if (JSFunction::Cast(result.GetTaggedObject())->GetMethod() ==
|
||||
JSFunction::Cast(func.GetTaggedObject())->GetMethod()) {
|
||||
@ -114,7 +114,7 @@ JSTaggedValue InvokeCache::Construct(JSThread *thread, JSTaggedValue firstValue,
|
||||
params.newTarget = newTgt.GetTaggedType();
|
||||
params.thisArg = obj.GetTaggedType();
|
||||
params.argc = length;
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
JSTaggedValue value = frameHandler.GetVRegValue(firstArgIdx + i);
|
||||
values.emplace_back(value.GetRawData());
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ void ProfileTypeAccessor::AddHandlerWithoutKey(JSHandle<JSTaggedValue> dynclass,
|
||||
if (!profileData.IsWeak() && profileData.IsTaggedArray()) { // POLY
|
||||
ASSERT(profileTypeInfo_->Get(index + 1) == JSTaggedValue::Hole());
|
||||
JSHandle<TaggedArray> arr(thread_, profileData);
|
||||
const array_size_t step = 2;
|
||||
array_size_t newLen = arr->GetLength() + step;
|
||||
const uint32_t step = 2;
|
||||
uint32_t newLen = arr->GetLength() + step;
|
||||
if (newLen > CACHE_MAX_LEN) {
|
||||
profileTypeInfo_->Set(thread_, index, JSTaggedValue::Hole());
|
||||
profileTypeInfo_->Set(thread_, index + 1, JSTaggedValue::Hole());
|
||||
@ -64,7 +64,7 @@ void ProfileTypeAccessor::AddHandlerWithoutKey(JSHandle<JSTaggedValue> dynclass,
|
||||
}
|
||||
auto factory = thread_->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> newArr = factory->NewTaggedArray(newLen);
|
||||
array_size_t i = 0;
|
||||
uint32_t i = 0;
|
||||
for (; i < arr->GetLength(); i += step) {
|
||||
newArr->Set(thread_, i, arr->Get(i));
|
||||
newArr->Set(thread_, i + 1, arr->Get(i + 1));
|
||||
@ -78,7 +78,7 @@ void ProfileTypeAccessor::AddHandlerWithoutKey(JSHandle<JSTaggedValue> dynclass,
|
||||
// MONO to POLY
|
||||
auto factory = thread_->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> newArr = factory->NewTaggedArray(POLY_CASE_NUM);
|
||||
array_size_t arrIndex = 0;
|
||||
uint32_t arrIndex = 0;
|
||||
newArr->Set(thread_, arrIndex++, profileTypeInfo_->Get(index));
|
||||
newArr->Set(thread_, arrIndex++, profileTypeInfo_->Get(index + 1));
|
||||
newArr->Set(thread_, arrIndex++, GetWeakRef(dynclass.GetTaggedValue()));
|
||||
@ -117,9 +117,9 @@ void ProfileTypeAccessor::AddHandlerWithKey(JSHandle<JSTaggedValue> key, JSHandl
|
||||
JSTaggedValue patchValue = profileTypeInfo_->Get(index + 1);
|
||||
ASSERT(patchValue.IsTaggedArray());
|
||||
JSHandle<TaggedArray> arr(thread_, patchValue);
|
||||
const array_size_t step = 2;
|
||||
const uint32_t step = 2;
|
||||
if (arr->GetLength() > step) { // POLY
|
||||
array_size_t newLen = arr->GetLength() + step;
|
||||
uint32_t newLen = arr->GetLength() + step;
|
||||
if (newLen > CACHE_MAX_LEN) {
|
||||
profileTypeInfo_->Set(thread_, index, JSTaggedValue::Hole());
|
||||
profileTypeInfo_->Set(thread_, index + 1, JSTaggedValue::Hole());
|
||||
@ -129,7 +129,7 @@ void ProfileTypeAccessor::AddHandlerWithKey(JSHandle<JSTaggedValue> key, JSHandl
|
||||
JSHandle<TaggedArray> newArr = factory->NewTaggedArray(newLen);
|
||||
newArr->Set(thread_, 0, GetWeakRef(dynclass.GetTaggedValue()));
|
||||
newArr->Set(thread_, 1, handler.GetTaggedValue());
|
||||
for (array_size_t i = 0; i < arr->GetLength(); i += step) {
|
||||
for (uint32_t i = 0; i < arr->GetLength(); i += step) {
|
||||
newArr->Set(thread_, i + step, arr->Get(i));
|
||||
newArr->Set(thread_, i + step + 1, arr->Get(i + 1));
|
||||
}
|
||||
@ -139,7 +139,7 @@ void ProfileTypeAccessor::AddHandlerWithKey(JSHandle<JSTaggedValue> key, JSHandl
|
||||
// MONO
|
||||
auto factory = thread_->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> newArr = factory->NewTaggedArray(POLY_CASE_NUM);
|
||||
array_size_t arrIndex = 0;
|
||||
uint32_t arrIndex = 0;
|
||||
newArr->Set(thread_, arrIndex++, arr->Get(0));
|
||||
newArr->Set(thread_, arrIndex++, arr->Get(1));
|
||||
newArr->Set(thread_, arrIndex++, GetWeakRef(dynclass.GetTaggedValue()));
|
||||
@ -163,7 +163,7 @@ void ProfileTypeAccessor::AddGlobalHandlerKey(JSHandle<JSTaggedValue> key, JSHan
|
||||
}
|
||||
ASSERT(indexVal.IsTaggedArray());
|
||||
JSHandle<TaggedArray> arr(thread_, indexVal);
|
||||
array_size_t newLen = arr->GetLength() + step;
|
||||
uint32_t newLen = arr->GetLength() + step;
|
||||
if (newLen > CACHE_MAX_LEN) {
|
||||
profileTypeInfo_->Set(thread_, index, JSTaggedValue::Hole());
|
||||
return;
|
||||
@ -173,7 +173,7 @@ void ProfileTypeAccessor::AddGlobalHandlerKey(JSHandle<JSTaggedValue> key, JSHan
|
||||
newArr->Set(thread_, 0, GetWeakRef(key.GetTaggedValue()));
|
||||
newArr->Set(thread_, 1, handler.GetTaggedValue());
|
||||
|
||||
for (array_size_t i = 0; i < arr->GetLength(); i += step) {
|
||||
for (uint32_t i = 0; i < arr->GetLength(); i += step) {
|
||||
newArr->Set(thread_, i + step, arr->Get(i));
|
||||
newArr->Set(thread_, i + step + 1, arr->Get(i + 1));
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ std::string ICKindToString(ICKind kind);
|
||||
|
||||
class ProfileTypeInfo : public TaggedArray {
|
||||
public:
|
||||
static const array_size_t MAX_FUNC_CACHE_INDEX = std::numeric_limits<uint32_t>::max();
|
||||
static const uint32_t MAX_FUNC_CACHE_INDEX = std::numeric_limits<uint32_t>::max();
|
||||
static constexpr uint32_t INVALID_SLOT_INDEX = 0xFF;
|
||||
|
||||
static ProfileTypeInfo *Cast(TaggedObject *object)
|
||||
|
@ -18,12 +18,12 @@
|
||||
|
||||
namespace panda::ecmascript {
|
||||
JSHandle<ChangeListener> ChangeListener::Add(const JSThread *thread, const JSHandle<ChangeListener> &array,
|
||||
const JSHandle<JSHClass> &value, array_size_t *index)
|
||||
const JSHandle<JSHClass> &value, uint32_t *index)
|
||||
{
|
||||
JSTaggedValue weakValue;
|
||||
if (!array->Full()) {
|
||||
weakValue = JSTaggedValue(value.GetTaggedValue().CreateAndGetWeakRef());
|
||||
array_size_t arrayIndex = array->PushBack(thread, weakValue);
|
||||
uint32_t arrayIndex = array->PushBack(thread, weakValue);
|
||||
if (arrayIndex != TaggedArray::MAX_ARRAY_INDEX) {
|
||||
if (index != nullptr) {
|
||||
*index = arrayIndex;
|
||||
@ -33,7 +33,7 @@ JSHandle<ChangeListener> ChangeListener::Add(const JSThread *thread, const JSHan
|
||||
UNREACHABLE();
|
||||
}
|
||||
// if exist hole, use it.
|
||||
array_size_t holeIndex = CheckHole(array);
|
||||
uint32_t holeIndex = CheckHole(array);
|
||||
if (holeIndex != TaggedArray::MAX_ARRAY_INDEX) {
|
||||
weakValue = JSTaggedValue(value.GetTaggedValue().CreateAndGetWeakRef());
|
||||
array->Set(thread, holeIndex, weakValue);
|
||||
@ -45,7 +45,7 @@ JSHandle<ChangeListener> ChangeListener::Add(const JSThread *thread, const JSHan
|
||||
// the vector is full and no hole exists.
|
||||
JSHandle<WeakVector> newArray = WeakVector::Grow(thread, JSHandle<WeakVector>(array), array->GetCapacity() + 1);
|
||||
weakValue = JSTaggedValue(value.GetTaggedValue().CreateAndGetWeakRef());
|
||||
array_size_t arrayIndex = newArray->PushBack(thread, weakValue);
|
||||
uint32_t arrayIndex = newArray->PushBack(thread, weakValue);
|
||||
ASSERT(arrayIndex != TaggedArray::MAX_ARRAY_INDEX);
|
||||
if (index != nullptr) {
|
||||
*index = arrayIndex;
|
||||
@ -53,9 +53,9 @@ JSHandle<ChangeListener> ChangeListener::Add(const JSThread *thread, const JSHan
|
||||
return JSHandle<ChangeListener>(newArray);
|
||||
}
|
||||
|
||||
array_size_t ChangeListener::CheckHole(const JSHandle<ChangeListener> &array)
|
||||
uint32_t ChangeListener::CheckHole(const JSHandle<ChangeListener> &array)
|
||||
{
|
||||
for (array_size_t i = 0; i < array->GetEnd(); i++) {
|
||||
for (uint32_t i = 0; i < array->GetEnd(); i++) {
|
||||
JSTaggedValue value = array->Get(i);
|
||||
if (value == JSTaggedValue::Hole() || value == JSTaggedValue::Undefined()) {
|
||||
return i;
|
||||
@ -64,7 +64,7 @@ array_size_t ChangeListener::CheckHole(const JSHandle<ChangeListener> &array)
|
||||
return TaggedArray::MAX_ARRAY_INDEX;
|
||||
}
|
||||
|
||||
JSTaggedValue ChangeListener::Get(array_size_t index)
|
||||
JSTaggedValue ChangeListener::Get(uint32_t index)
|
||||
{
|
||||
JSTaggedValue value = WeakVector::Get(index);
|
||||
if (!value.IsHeapObject()) {
|
||||
|
@ -63,11 +63,11 @@ public:
|
||||
}
|
||||
|
||||
static JSHandle<ChangeListener> Add(const JSThread *thread, const JSHandle<ChangeListener> &array,
|
||||
const JSHandle<JSHClass> &value, array_size_t *index);
|
||||
const JSHandle<JSHClass> &value, uint32_t *index);
|
||||
|
||||
static array_size_t CheckHole(const JSHandle<ChangeListener> &array);
|
||||
static uint32_t CheckHole(const JSHandle<ChangeListener> &array);
|
||||
|
||||
JSTaggedValue Get(array_size_t index);
|
||||
JSTaggedValue Get(uint32_t index);
|
||||
};
|
||||
} // namespace ecmascript
|
||||
} // namespace panda
|
||||
|
@ -22,14 +22,14 @@ void InternalCallParams::MakeArgv(const EcmaRuntimeCallInfo *info, uint32_t posi
|
||||
uint32_t length = mayLenth > 0 ? mayLenth : 0;
|
||||
if (LIKELY(length <= InternalCallParams::RESERVE_INTERNAL_CALL_PARAMS_FIXED_LENGTH)) {
|
||||
EnableFixedModeAndSetLength(length);
|
||||
for (array_size_t index = 0; index < length; ++index) {
|
||||
for (uint32_t index = 0; index < length; ++index) {
|
||||
SetFixedBuffer(index, info->GetCallArg(index + position));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
EnableVariableModeAndSetLength(length);
|
||||
for (array_size_t index = 0; index < length; ++index) {
|
||||
for (uint32_t index = 0; index < length; ++index) {
|
||||
SetVariableBuffer(index, info->GetCallArg(index + position));
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ void InternalCallParams::MakeArgListWithHole(const TaggedArray *argv, uint32_t l
|
||||
ASSERT(length <= argv->GetLength());
|
||||
if (LIKELY(length <= InternalCallParams::RESERVE_INTERNAL_CALL_PARAMS_FIXED_LENGTH)) {
|
||||
EnableFixedModeAndSetLength(length);
|
||||
for (array_size_t index = 0; index < length; ++index) {
|
||||
for (uint32_t index = 0; index < length; ++index) {
|
||||
auto value = argv->Get(index);
|
||||
SetFixedBuffer(index, value.IsHole() ? JSTaggedValue::Undefined() : value);
|
||||
}
|
||||
@ -50,7 +50,7 @@ void InternalCallParams::MakeArgListWithHole(const TaggedArray *argv, uint32_t l
|
||||
}
|
||||
|
||||
EnableVariableModeAndSetLength(length);
|
||||
for (array_size_t index = 0; index < length; ++index) {
|
||||
for (uint32_t index = 0; index < length; ++index) {
|
||||
auto value = argv->Get(index);
|
||||
SetVariableBuffer(index, value.IsHole() ? JSTaggedValue::Undefined() : value);
|
||||
}
|
||||
@ -61,14 +61,14 @@ void InternalCallParams::MakeArgList(const TaggedArray *argv)
|
||||
uint32_t length = argv->GetLength();
|
||||
if (LIKELY(length <= InternalCallParams::RESERVE_INTERNAL_CALL_PARAMS_FIXED_LENGTH)) {
|
||||
EnableFixedModeAndSetLength(length);
|
||||
for (array_size_t index = 0; index < length; ++index) {
|
||||
for (uint32_t index = 0; index < length; ++index) {
|
||||
SetFixedBuffer(index, argv->Get(index));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
EnableVariableModeAndSetLength(length);
|
||||
for (array_size_t index = 0; index < length; ++index) {
|
||||
for (uint32_t index = 0; index < length; ++index) {
|
||||
SetVariableBuffer(index, argv->Get(index));
|
||||
}
|
||||
}
|
||||
@ -87,7 +87,7 @@ void InternalCallParams::MakeBoundArgv(const JSThread *thread, const JSHandle<JS
|
||||
SetFixedBuffer(index, GetFixedBuffer(index - boundLength));
|
||||
}
|
||||
|
||||
for (array_size_t index = 0; index < boundLength; ++index) {
|
||||
for (uint32_t index = 0; index < boundLength; ++index) {
|
||||
SetFixedBuffer(index, boundArgs->Get(index));
|
||||
}
|
||||
return;
|
||||
@ -97,11 +97,11 @@ void InternalCallParams::MakeBoundArgv(const JSThread *thread, const JSHandle<JS
|
||||
if (IsFixedMode()) {
|
||||
// enable variable mode not clear fixed buffer
|
||||
EnableVariableModeAndSetLength(length);
|
||||
for (array_size_t index = 0; index < boundLength; ++index) {
|
||||
for (uint32_t index = 0; index < boundLength; ++index) {
|
||||
SetVariableBuffer(index, boundArgs->Get(index));
|
||||
}
|
||||
|
||||
for (array_size_t index = boundLength; index < length; ++index) {
|
||||
for (uint32_t index = boundLength; index < length; ++index) {
|
||||
SetVariableBuffer(index, GetFixedBuffer(index - boundLength));
|
||||
}
|
||||
return;
|
||||
|
@ -248,7 +248,7 @@ PropertyAttributes FastRuntimeStub::AddPropertyByName(JSThread *thread, JSHandle
|
||||
}
|
||||
|
||||
JSMutableHandle<TaggedArray> array(thread, objHandle->GetProperties());
|
||||
array_size_t length = array->GetLength();
|
||||
uint32_t length = array->GetLength();
|
||||
if (length == 0) {
|
||||
length = JSObject::MIN_PROPERTIES_LENGTH;
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
@ -259,7 +259,7 @@ PropertyAttributes FastRuntimeStub::AddPropertyByName(JSThread *thread, JSHandle
|
||||
if (!array->IsDictionaryMode()) {
|
||||
attr.SetIsInlinedProps(false);
|
||||
|
||||
array_size_t nonInlinedProps = objHandle->GetJSHClass()->GetNextNonInlinedPropsIndex();
|
||||
uint32_t nonInlinedProps = objHandle->GetJSHClass()->GetNextNonInlinedPropsIndex();
|
||||
ASSERT(length >= nonInlinedProps);
|
||||
// if array is full, grow array or change to dictionary mode
|
||||
if (length == nonInlinedProps) {
|
||||
@ -273,7 +273,7 @@ PropertyAttributes FastRuntimeStub::AddPropertyByName(JSThread *thread, JSHandle
|
||||
return attr;
|
||||
}
|
||||
// Grow properties array size
|
||||
array_size_t capacity = JSObject::ComputePropertyCapacity(length);
|
||||
uint32_t capacity = JSObject::ComputePropertyCapacity(length);
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
array.Update(factory->CopyArray(array, length, capacity).GetTaggedValue());
|
||||
objHandle->SetProperties(thread, array.GetTaggedValue());
|
||||
|
@ -112,7 +112,7 @@ JSTaggedValue ConstructGeneric(JSThread *thread, JSHandle<JSFunction> ctor, JSHa
|
||||
obj = JSHandle<JSTaggedValue>(factory->NewJSObjectByConstructor(ctor, newTgt));
|
||||
}
|
||||
uint32_t preArgsSize = preArgs->IsUndefined() ? 0 : JSHandle<TaggedArray>::Cast(preArgs)->GetLength();
|
||||
const array_size_t size = preArgsSize + argsCount;
|
||||
const uint32_t size = preArgsSize + argsCount;
|
||||
CVector<JSTaggedType> values;
|
||||
values.reserve(size);
|
||||
|
||||
@ -131,17 +131,17 @@ JSTaggedValue ConstructGeneric(JSThread *thread, JSHandle<JSFunction> ctor, JSHa
|
||||
// add preArgs when boundfunction is encountered
|
||||
if (preArgsSize > 0) {
|
||||
JSHandle<TaggedArray> tgaPreArgs = JSHandle<TaggedArray>::Cast(preArgs);
|
||||
for (array_size_t i = 0; i < preArgsSize; ++i) {
|
||||
for (uint32_t i = 0; i < preArgsSize; ++i) {
|
||||
JSTaggedValue value = tgaPreArgs->Get(i);
|
||||
values.emplace_back(value.GetRawData());
|
||||
}
|
||||
for (array_size_t i = 0; i < argsCount; ++i) {
|
||||
for (uint32_t i = 0; i < argsCount; ++i) {
|
||||
JSTaggedValue value = frameHandler.GetVRegValue(baseArgLocation + i);
|
||||
values.emplace_back(value.GetRawData());
|
||||
}
|
||||
params.argv = values.data();
|
||||
} else {
|
||||
for (array_size_t i = 0; i < argsCount; ++i) {
|
||||
for (uint32_t i = 0; i < argsCount; ++i) {
|
||||
JSTaggedValue value = frameHandler.GetVRegValue(baseArgLocation + i);
|
||||
values.emplace_back(value.GetRawData());
|
||||
}
|
||||
@ -212,17 +212,17 @@ JSTaggedValue ConstructProxy(JSThread *thread, JSHandle<JSProxy> ctor, JSHandle<
|
||||
|
||||
// 8.Let argArray be CreateArrayFromList(argumentsList).
|
||||
uint32_t preArgsSize = preArgs->IsUndefined() ? 0 : JSHandle<TaggedArray>::Cast(preArgs)->GetLength();
|
||||
const array_size_t size = preArgsSize + argsCount;
|
||||
const uint32_t size = preArgsSize + argsCount;
|
||||
JSHandle<TaggedArray> args = thread->GetEcmaVM()->GetFactory()->NewTaggedArray(size);
|
||||
JSHandle<TaggedArray> tgaPreArgs = JSHandle<TaggedArray>::Cast(preArgs);
|
||||
if (preArgsSize > 0) {
|
||||
for (array_size_t i = 0; i < preArgsSize; ++i) {
|
||||
for (uint32_t i = 0; i < preArgsSize; ++i) {
|
||||
JSTaggedValue value = tgaPreArgs->Get(i);
|
||||
args->Set(thread, i, value);
|
||||
}
|
||||
}
|
||||
InterpretedFrameHandler frameHandler(thread);
|
||||
for (array_size_t i = 0; i < argsCount; ++i) {
|
||||
for (uint32_t i = 0; i < argsCount; ++i) {
|
||||
JSTaggedValue value = frameHandler.GetVRegValue(baseArgLocation + i);
|
||||
args->Set(thread, i + preArgsSize, value);
|
||||
}
|
||||
|
@ -445,14 +445,14 @@ JSTaggedValue SlowRuntimeStub::CreateObjectWithExcludedKeys(JSThread *thread, ui
|
||||
|
||||
ASSERT(objVal.IsJSObject());
|
||||
JSHandle<JSObject> obj(thread, objVal);
|
||||
array_size_t numExcludedKeys = 0;
|
||||
uint32_t numExcludedKeys = 0;
|
||||
JSHandle<TaggedArray> excludedKeys = factory->NewTaggedArray(numKeys + 1);
|
||||
InterpretedFrameHandler frameHandler(thread);
|
||||
JSTaggedValue excludedKey = frameHandler.GetVRegValue(firstArgRegIdx);
|
||||
if (!excludedKey.IsUndefined()) {
|
||||
numExcludedKeys = numKeys + 1;
|
||||
excludedKeys->Set(thread, 0, excludedKey);
|
||||
for (array_size_t i = 1; i < numExcludedKeys; i++) {
|
||||
for (uint32_t i = 1; i < numExcludedKeys; i++) {
|
||||
excludedKey = frameHandler.GetVRegValue(firstArgRegIdx + i);
|
||||
excludedKeys->Set(thread, i, excludedKey);
|
||||
}
|
||||
@ -672,7 +672,7 @@ JSTaggedValue SlowRuntimeStub::NewObjSpreadDyn(JSThread *thread, JSTaggedValue f
|
||||
|
||||
uint32_t length = JSHandle<JSArray>::Cast(jsArray)->GetArrayLength();
|
||||
JSHandle<TaggedArray> argsArray = factory->NewTaggedArray(length);
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
auto prop = JSTaggedValue::GetProperty(thread, jsArray, i).GetValue();
|
||||
argsArray->Set(thread, i, prop);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
@ -1060,8 +1060,8 @@ JSTaggedValue SlowRuntimeStub::CopyDataProperties(JSThread *thread, JSTaggedValu
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
|
||||
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
|
||||
array_size_t keysLen = keys->GetLength();
|
||||
for (array_size_t i = 0; i < keysLen; i++) {
|
||||
uint32_t keysLen = keys->GetLength();
|
||||
for (uint32_t i = 0; i < keysLen; i++) {
|
||||
PropertyDescriptor desc(thread);
|
||||
key.Update(keys->Get(i));
|
||||
bool success = JSTaggedValue::GetOwnProperty(thread, srcHandle, key, desc);
|
||||
@ -1102,7 +1102,7 @@ JSTaggedValue SlowRuntimeStub::GetUnmapedArgs(JSThread *thread, JSTaggedType *sp
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<GlobalEnv> globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
|
||||
JSHandle<TaggedArray> argumentsList = factory->NewTaggedArray(actualNumArgs);
|
||||
for (array_size_t i = 0; i < actualNumArgs; ++i) {
|
||||
for (uint32_t i = 0; i < actualNumArgs; ++i) {
|
||||
argumentsList->Set(thread, i,
|
||||
JSTaggedValue(sp[startIdx + i])); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
}
|
||||
@ -1495,9 +1495,9 @@ JSTaggedValue SlowRuntimeStub::StArraySpread(JSThread *thread, JSTaggedValue dst
|
||||
if (srcHandle->IsString()) {
|
||||
JSHandle<EcmaString> srcString = JSTaggedValue::ToString(thread, srcHandle);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
array_size_t dstLen = index.GetInt();
|
||||
array_size_t strLen = srcString->GetLength();
|
||||
for (array_size_t i = 0; i < strLen; i++) {
|
||||
uint32_t dstLen = index.GetInt();
|
||||
uint32_t strLen = srcString->GetLength();
|
||||
for (uint32_t i = 0; i < strLen; i++) {
|
||||
uint16_t res = srcString->At<false>(i);
|
||||
JSHandle<JSTaggedValue> strValue(factory->NewFromUtf16Literal(&res, 1));
|
||||
JSTaggedValue::SetProperty(thread, dstHandle, dstLen + i, strValue, true);
|
||||
|
@ -22,7 +22,7 @@ namespace panda::ecmascript {
|
||||
void JSArrayList::Add(JSThread *thread, const JSHandle<JSArrayList> &arrayList, const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
// GrowCapacity
|
||||
array_size_t length = arrayList->GetLength().GetArrayLength();
|
||||
uint32_t length = arrayList->GetLength().GetArrayLength();
|
||||
JSHandle<TaggedArray> elements = GrowCapacity(thread, arrayList, length + 1);
|
||||
|
||||
ASSERT(!elements->IsDictionaryMode());
|
||||
@ -31,14 +31,14 @@ void JSArrayList::Add(JSThread *thread, const JSHandle<JSArrayList> &arrayList,
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> JSArrayList::GrowCapacity(const JSThread *thread, const JSHandle<JSArrayList> &obj,
|
||||
array_size_t capacity)
|
||||
uint32_t capacity)
|
||||
{
|
||||
JSHandle<TaggedArray> oldElements(thread, obj->GetElements());
|
||||
array_size_t oldLength = oldElements->GetLength();
|
||||
uint32_t oldLength = oldElements->GetLength();
|
||||
if (capacity < oldLength) {
|
||||
return oldElements;
|
||||
}
|
||||
array_size_t newCapacity = ComputeCapacity(capacity);
|
||||
uint32_t newCapacity = ComputeCapacity(capacity);
|
||||
JSHandle<TaggedArray> newElements =
|
||||
thread->GetEcmaVM()->GetFactory()->CopyArray(oldElements, oldLength, newCapacity);
|
||||
|
||||
@ -73,12 +73,12 @@ bool JSArrayList::Delete(JSThread *thread, const JSHandle<JSArrayList> &obj, con
|
||||
if (UNLIKELY(JSTaggedValue::ToElementIndex(key.GetTaggedValue(), &index))) {
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Can not delete a type other than number", false);
|
||||
}
|
||||
array_size_t length = obj->GetLength().GetArrayLength();
|
||||
uint32_t length = obj->GetLength().GetArrayLength();
|
||||
if (index < 0 || index >= length) {
|
||||
THROW_RANGE_ERROR_AND_RETURN(thread, "Delete property index out-of-bounds", false);
|
||||
}
|
||||
TaggedArray *elements = TaggedArray::Cast(obj->GetElements().GetTaggedObject());
|
||||
for (array_size_t i = 0; i < length - 1; i++) {
|
||||
for (uint32_t i = 0; i < length - 1; i++) {
|
||||
elements->Set(thread, i, elements->Get(i + 1));
|
||||
}
|
||||
obj->SetLength(thread, JSTaggedValue(--length));
|
||||
@ -93,11 +93,11 @@ bool JSArrayList::Has(JSTaggedValue value) const
|
||||
|
||||
JSHandle<TaggedArray> JSArrayList::OwnKeys(JSThread *thread, const JSHandle<JSArrayList> &obj)
|
||||
{
|
||||
array_size_t length = obj->GetLength().GetArrayLength();
|
||||
uint32_t length = obj->GetLength().GetArrayLength();
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> keys = factory->NewTaggedArray(length);
|
||||
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
keys->Set(thread, i, JSTaggedValue(i));
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ bool JSArrayList::GetOwnProperty(JSThread *thread, const JSHandle<JSArrayList> &
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Can not get property whose type is not number", false);
|
||||
}
|
||||
|
||||
array_size_t length = obj->GetLength().GetArrayLength();
|
||||
uint32_t length = obj->GetLength().GetArrayLength();
|
||||
if (index < 0 || index >= length) {
|
||||
THROW_RANGE_ERROR_AND_RETURN(thread, "Get property index out-of-bounds", false);
|
||||
}
|
||||
|
@ -51,13 +51,13 @@ public:
|
||||
DECL_VISIT_OBJECT_FOR_JS_OBJECT(JSObject, LENGTH_OFFSET, SIZE)
|
||||
DECL_DUMP()
|
||||
private:
|
||||
inline static array_size_t ComputeCapacity(array_size_t oldCapacity)
|
||||
inline static uint32_t ComputeCapacity(uint32_t oldCapacity)
|
||||
{
|
||||
array_size_t newCapacity = oldCapacity + (oldCapacity >> 1U);
|
||||
uint32_t newCapacity = oldCapacity + (oldCapacity >> 1U);
|
||||
return newCapacity > DEFAULT_CAPACITY_LENGTH ? newCapacity : DEFAULT_CAPACITY_LENGTH;
|
||||
}
|
||||
static JSHandle<TaggedArray> GrowCapacity(const JSThread *thread, const JSHandle<JSArrayList> &obj,
|
||||
array_size_t capacity);
|
||||
uint32_t capacity);
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
|
@ -503,8 +503,8 @@ JSHandle<JSObject> JSDateTimeFormat::ToDateTimeOptions(JSThread *thread, const J
|
||||
array->Set(thread, 2, globalConst->GetHandledMonthString()); // 2 means the third slot
|
||||
array->Set(thread, 3, globalConst->GetHandledDayString()); // 3 means the fourth slot
|
||||
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
|
||||
array_size_t len = array->GetLength();
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
uint32_t len = array->GetLength();
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
key.Update(array->Get(thread, i));
|
||||
OperationResult operationResult = JSObject::GetProperty(thread, optionsResult, key);
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
|
||||
@ -527,8 +527,8 @@ JSHandle<JSObject> JSDateTimeFormat::ToDateTimeOptions(JSThread *thread, const J
|
||||
array->Set(thread, 3, globalConst->GetHandledSecondString()); // 3 means the third slot
|
||||
array->Set(thread, 4, globalConst->GetHandledFractionalSecondDigitsString()); // 4 means the fourth slot
|
||||
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
|
||||
array_size_t len = array->GetLength();
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
uint32_t len = array->GetLength();
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
key.Update(array->Get(thread, i));
|
||||
OperationResult operationResult = JSObject::GetProperty(thread, optionsResult, key);
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
|
||||
@ -570,8 +570,8 @@ JSHandle<JSObject> JSDateTimeFormat::ToDateTimeOptions(JSThread *thread, const J
|
||||
array->Set(thread, 1, globalConst->GetHandledMonthString());
|
||||
array->Set(thread, 2, globalConst->GetHandledDayString()); // 2 means the third slot
|
||||
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
|
||||
array_size_t len = array->GetLength();
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
uint32_t len = array->GetLength();
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
key.Update(array->Get(thread, i));
|
||||
JSObject::CreateDataPropertyOrThrow(thread, optionsResult, key, globalConst->GetHandledNumericString());
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
|
||||
@ -587,8 +587,8 @@ JSHandle<JSObject> JSDateTimeFormat::ToDateTimeOptions(JSThread *thread, const J
|
||||
array->Set(thread, 1, globalConst->GetHandledMinuteString());
|
||||
array->Set(thread, 2, globalConst->GetHandledSecondString()); // 2 means the third slot
|
||||
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
|
||||
array_size_t len = array->GetLength();
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
uint32_t len = array->GetLength();
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
key.Update(array->Get(thread, i));
|
||||
JSObject::CreateDataPropertyOrThrow(thread, optionsResult, key, globalConst->GetHandledNumericString());
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
|
||||
|
@ -193,8 +193,8 @@ void JSForInIterator::SlowGetAllEnumKeys(JSThread *thread, const JSHandle<JSForI
|
||||
JSMutableHandle<JSTaggedValue> value(thread, JSTaggedValue::Undefined());
|
||||
JSMutableHandle<TaggedQueue> remaining(thread, it->GetRemainingKeys());
|
||||
JSHandle<TaggedArray> arr = JSTaggedValue::GetOwnPropertyKeys(thread, object);
|
||||
array_size_t len = arr->GetLength();
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
uint32_t len = arr->GetLength();
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
value.Update(arr->Get(i));
|
||||
if (value->IsString()) {
|
||||
TaggedQueue *newQueue = TaggedQueue::Push(thread, remaining, value);
|
||||
@ -232,8 +232,8 @@ std::pair<JSTaggedValue, bool> JSForInIterator::NextInternal(JSThread *thread, c
|
||||
}
|
||||
JSHandle<JSTaggedValue> key(thread, r);
|
||||
bool has_same = false;
|
||||
array_size_t len = visited->Size();
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
uint32_t len = visited->Size();
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
if (JSTaggedValue::SameValue(r, visited->Get(i))) {
|
||||
has_same = true;
|
||||
break;
|
||||
|
@ -381,7 +381,7 @@ void JSHClass::RegisterOnProtoChain(const JSThread *thread, const JSHandle<JSHCl
|
||||
} else {
|
||||
listenersHandle = JSHandle<ChangeListener>(thread, listeners);
|
||||
}
|
||||
array_size_t registerIndex = 0;
|
||||
uint32_t registerIndex = 0;
|
||||
JSHandle<ChangeListener> newListeners = ChangeListener::Add(thread, listenersHandle, user, ®isterIndex);
|
||||
userDetails->SetRegisterIndex(thread, JSTaggedValue(registerIndex));
|
||||
protoDetails->SetChangeListener(thread, newListeners.GetTaggedValue());
|
||||
@ -402,7 +402,7 @@ bool JSHClass::UnregisterOnProtoChain(const JSThread *thread, const JSHandle<JSH
|
||||
return listeners != JSTaggedValue(0);
|
||||
}
|
||||
JSHandle<ProtoChangeDetails> currentDetails = GetProtoChangeDetails(thread, jshclass);
|
||||
array_size_t index = currentDetails->GetRegisterIndex().GetArrayLength();
|
||||
uint32_t index = currentDetails->GetRegisterIndex().GetArrayLength();
|
||||
if (JSTaggedValue(index) == JSTaggedValue(ProtoChangeDetails::UNREGISTERED)) {
|
||||
return false;
|
||||
}
|
||||
@ -457,7 +457,7 @@ void JSHClass::NoticeThroughChain(const JSThread *thread, const JSHandle<JSHClas
|
||||
return;
|
||||
}
|
||||
ChangeListener *listeners = ChangeListener::Cast(listenersValue.GetTaggedObject());
|
||||
for (array_size_t i = 0; i < listeners->GetEnd(); i++) {
|
||||
for (uint32_t i = 0; i < listeners->GetEnd(); i++) {
|
||||
JSTaggedValue temp = listeners->Get(i);
|
||||
if (temp.IsJSHClass()) {
|
||||
NoticeThroughChain(thread, JSHandle<JSHClass>(thread, listeners->Get(i).GetTaggedObject()));
|
||||
|
@ -232,7 +232,7 @@ JSHandle<TaggedArray> JSLocale::CanonicalizeHelper(JSThread *thread, const JSHan
|
||||
// 7. Repeat, while k < len
|
||||
JSMutableHandle<JSTaggedValue> pk(thread, JSTaggedValue::Undefined());
|
||||
JSMutableHandle<JSTaggedValue> tag(thread, JSTaggedValue::Undefined());
|
||||
array_size_t index = 0;
|
||||
uint32_t index = 0;
|
||||
JSHandle<JSTaggedValue> objTagged = JSHandle<JSTaggedValue>::Cast(obj);
|
||||
for (uint32_t k = 0; k < requestedLocalesLen; k++) {
|
||||
// a. Let Pk be ToString(k).
|
||||
@ -271,8 +271,8 @@ JSHandle<TaggedArray> JSLocale::CanonicalizeHelper(JSThread *thread, const JSHan
|
||||
}
|
||||
// vii. If canonicalizedTag is not an element of seen, append canonicalizedTag as the last element of seen.
|
||||
bool isExist = false;
|
||||
array_size_t len = seen->GetLength();
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
uint32_t len = seen->GetLength();
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
if (JSTaggedValue::SameValue(seen->Get(thread, i), tag.GetTaggedValue())) {
|
||||
isExist = true;
|
||||
}
|
||||
@ -297,11 +297,11 @@ std::string JSLocale::BestAvailableLocale(JSThread *thread, const JSHandle<Tagge
|
||||
std::string localeCandidate = locale;
|
||||
std::string undefined = std::string();
|
||||
// 2. Repeat,
|
||||
array_size_t length = availableLocales->GetLength();
|
||||
uint32_t length = availableLocales->GetLength();
|
||||
JSMutableHandle<EcmaString> item(thread, JSTaggedValue::Undefined());
|
||||
while (true) {
|
||||
// a. If availableLocales contains an element equal to candidate, return candidate.
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
item.Update(availableLocales->Get(thread, i));
|
||||
std::string itemStr = ConvertToStdString(item);
|
||||
if (itemStr == localeCandidate) {
|
||||
@ -331,9 +331,9 @@ JSHandle<EcmaString> JSLocale::LookupMatcher(JSThread *thread, const JSHandle<Ta
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
// 1. Let result be a new Record.
|
||||
// 2. For each element locale of requestedLocales in List order, do
|
||||
array_size_t length = requestedLocales->GetLength();
|
||||
uint32_t length = requestedLocales->GetLength();
|
||||
JSMutableHandle<EcmaString> locale(thread, JSTaggedValue::Undefined());
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
locale.Update(requestedLocales->Get(thread, i));
|
||||
// 2. a. Let noExtensionsLocale be the String value that is locale
|
||||
// with all Unicode locale extension sequences removed.
|
||||
@ -366,7 +366,7 @@ JSHandle<EcmaString> JSLocale::LookupMatcher(JSThread *thread, const JSHandle<Ta
|
||||
return factory->NewFromStdString(result.locale);
|
||||
}
|
||||
|
||||
icu::LocaleMatcher BuildLocaleMatcher(JSThread *thread, array_size_t *availableLength, UErrorCode *status,
|
||||
icu::LocaleMatcher BuildLocaleMatcher(JSThread *thread, uint32_t *availableLength, UErrorCode *status,
|
||||
const JSHandle<TaggedArray> &availableLocales)
|
||||
{
|
||||
std::string locale = JSLocale::ConvertToStdString(JSLocale::DefaultLocale(thread));
|
||||
@ -374,7 +374,7 @@ icu::LocaleMatcher BuildLocaleMatcher(JSThread *thread, array_size_t *availableL
|
||||
ASSERT_PRINT(U_SUCCESS(*status), "icu::Locale::forLanguageTag failed");
|
||||
icu::LocaleMatcher::Builder builder;
|
||||
builder.setDefaultLocale(&defaultLocale);
|
||||
array_size_t length = availableLocales->GetLength();
|
||||
uint32_t length = availableLocales->GetLength();
|
||||
|
||||
JSMutableHandle<EcmaString> item(thread, JSTaggedValue::Undefined());
|
||||
for (*availableLength = 0; *availableLength < length; ++(*availableLength)) {
|
||||
@ -397,11 +397,11 @@ JSHandle<EcmaString> JSLocale::BestFitMatcher(JSThread *thread, const JSHandle<T
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
array_size_t availableLength = availableLocales->GetLength();
|
||||
uint32_t availableLength = availableLocales->GetLength();
|
||||
icu::LocaleMatcher matcher = BuildLocaleMatcher(thread, &availableLength, &status, availableLocales);
|
||||
ASSERT(U_SUCCESS(status));
|
||||
|
||||
array_size_t requestedLocalesLength = requestedLocales->GetLength();
|
||||
uint32_t requestedLocalesLength = requestedLocales->GetLength();
|
||||
JSIntlIterator iter(requestedLocales, requestedLocalesLength);
|
||||
auto bestFit = matcher.getBestMatch(iter, status)->toLanguageTag<std::string>(status);
|
||||
|
||||
@ -409,7 +409,7 @@ JSHandle<EcmaString> JSLocale::BestFitMatcher(JSThread *thread, const JSHandle<T
|
||||
return DefaultLocale(thread);
|
||||
}
|
||||
|
||||
for (array_size_t i = 0; i < requestedLocalesLength; ++i) {
|
||||
for (uint32_t i = 0; i < requestedLocalesLength; ++i) {
|
||||
if (iter[i] == bestFit) {
|
||||
return JSHandle<EcmaString>(thread, requestedLocales->Get(thread, i));
|
||||
}
|
||||
@ -423,7 +423,7 @@ JSHandle<TaggedArray> JSLocale::LookupSupportedLocales(JSThread *thread, const J
|
||||
{
|
||||
uint32_t index = 0;
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
array_size_t length = requestedLocales->GetLength();
|
||||
uint32_t length = requestedLocales->GetLength();
|
||||
// 1. Let subset be a new empty List.
|
||||
JSHandle<TaggedArray> subset = factory->NewTaggedArray(length);
|
||||
JSMutableHandle<EcmaString> item(thread, JSTaggedValue::Undefined());
|
||||
@ -432,7 +432,7 @@ JSHandle<TaggedArray> JSLocale::LookupSupportedLocales(JSThread *thread, const J
|
||||
// removed.
|
||||
// b. Let availableLocale be BestAvailableLocale(availableLocales, noExtensionsLocale).
|
||||
// c. If availableLocale is not undefined, append locale to the end of subset.
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
item.Update(requestedLocales->Get(thread, i));
|
||||
ParsedLocale foundationResult = HandleLocale(item);
|
||||
std::string availableLocale = BestAvailableLocale(thread, availableLocales, foundationResult.base);
|
||||
@ -449,8 +449,8 @@ JSHandle<TaggedArray> JSLocale::BestFitSupportedLocales(JSThread *thread, const
|
||||
const JSHandle<TaggedArray> &requestedLocales)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
array_size_t requestLength = requestedLocales->GetLength();
|
||||
array_size_t availableLength = availableLocales->GetLength();
|
||||
uint32_t requestLength = requestedLocales->GetLength();
|
||||
uint32_t availableLength = availableLocales->GetLength();
|
||||
icu::LocaleMatcher matcher = BuildLocaleMatcher(thread, &availableLength, &status, availableLocales);
|
||||
ASSERT(U_SUCCESS(status));
|
||||
|
||||
@ -460,7 +460,7 @@ JSHandle<TaggedArray> JSLocale::BestFitSupportedLocales(JSThread *thread, const
|
||||
|
||||
uint32_t index = 0;
|
||||
JSMutableHandle<EcmaString> locale(thread, JSTaggedValue::Undefined());
|
||||
for (array_size_t i = 0; i < requestLength; ++i) {
|
||||
for (uint32_t i = 0; i < requestLength; ++i) {
|
||||
locale.Update(requestedLocales->Get(thread, i));
|
||||
if (EcmaString::StringsAreEqual(*locale, *defaultLocale)) {
|
||||
result->Set(thread, index++, locale.GetTaggedValue());
|
||||
|
@ -77,9 +77,9 @@ constexpr uint8_t INTL_INDEX_EIGHT = 8;
|
||||
|
||||
class JSIntlIterator : public icu::Locale::Iterator {
|
||||
public:
|
||||
JSIntlIterator(const JSHandle<TaggedArray> &data, array_size_t length) : length_(length), curIdx_(0)
|
||||
JSIntlIterator(const JSHandle<TaggedArray> &data, uint32_t length) : length_(length), curIdx_(0)
|
||||
{
|
||||
for (array_size_t idx = 0; idx < length; idx++) {
|
||||
for (uint32_t idx = 0; idx < length; idx++) {
|
||||
std::string str = base::StringHelper::ToStdString(EcmaString::Cast(data->Get(idx).GetTaggedObject()));
|
||||
data_.emplace_back(str);
|
||||
}
|
||||
@ -112,8 +112,8 @@ public:
|
||||
|
||||
private:
|
||||
std::vector<std::string> data_{};
|
||||
array_size_t length_{0};
|
||||
array_size_t curIdx_{0};
|
||||
uint32_t length_{0};
|
||||
uint32_t curIdx_{0};
|
||||
icu::Locale locale_{};
|
||||
};
|
||||
|
||||
|
@ -72,7 +72,7 @@ JSHandle<TaggedArray> JSObject::GrowElementsCapacity(const JSThread *thread, con
|
||||
uint32_t newCapacity = ComputeElementCapacity(capacity);
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> oldElements(thread, obj->GetElements());
|
||||
array_size_t oldLength = oldElements->GetLength();
|
||||
uint32_t oldLength = oldElements->GetLength();
|
||||
JSHandle<TaggedArray> newElements = factory->CopyArray(oldElements, oldLength, newCapacity);
|
||||
|
||||
obj->SetElements(thread, newElements);
|
||||
@ -136,7 +136,7 @@ JSHandle<NameDictionary> JSObject::TransitionToDictionary(const JSThread *thread
|
||||
// trim in-obj properties space
|
||||
if (numberInlinedProps > 0) {
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
array_size_t newSize = receiver->GetClass()->GetObjectSize();
|
||||
uint32_t newSize = receiver->GetClass()->GetObjectSize();
|
||||
size_t trimBytes = numberInlinedProps * JSTaggedValue::TaggedTypeSize();
|
||||
factory->FillFreeObject(ToUintPtr(*receiver) + newSize, trimBytes, RemoveSlots::YES);
|
||||
}
|
||||
@ -294,7 +294,7 @@ void JSObject::GetAllKeys(const JSThread *thread, const JSHandle<JSObject> &obj,
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> JSObject::GetAllEnumKeys(const JSThread *thread, const JSHandle<JSObject> &obj, int offset,
|
||||
uint32_t numOfKeys, array_size_t *keys)
|
||||
uint32_t numOfKeys, uint32_t *keys)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
if (obj->IsJSGlobalObject()) {
|
||||
@ -376,7 +376,7 @@ void JSObject::GetALLElementKeysIntoVector(const JSThread *thread, const JSHandl
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> JSObject::GetEnumElementKeys(JSThread *thread, const JSHandle<JSObject> &obj, int offset,
|
||||
uint32_t numOfElements, array_size_t *keys)
|
||||
uint32_t numOfElements, uint32_t *keys)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> elementArray = factory->NewTaggedArray(numOfElements);
|
||||
@ -1195,13 +1195,13 @@ bool JSObject::SetIntegrityLevel(JSThread *thread, const JSHandle<JSObject> &obj
|
||||
descNoConfWrite.SetConfigurable(false);
|
||||
|
||||
if (level == IntegrityLevel::SEALED) {
|
||||
array_size_t length = jshandleKeys->GetLength();
|
||||
uint32_t length = jshandleKeys->GetLength();
|
||||
if (length == 0) {
|
||||
return true;
|
||||
}
|
||||
auto key = jshandleKeys->Get(0);
|
||||
JSMutableHandle<JSTaggedValue> handleKey(thread, key);
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
auto taggedKey = JSTaggedValue(jshandleKeys->Get(i));
|
||||
handleKey.Update(taggedKey);
|
||||
[[maybe_unused]] bool success =
|
||||
@ -1209,13 +1209,13 @@ bool JSObject::SetIntegrityLevel(JSThread *thread, const JSHandle<JSObject> &obj
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false);
|
||||
}
|
||||
} else {
|
||||
array_size_t length = jshandleKeys->GetLength();
|
||||
uint32_t length = jshandleKeys->GetLength();
|
||||
if (length == 0) {
|
||||
return true;
|
||||
}
|
||||
auto key = jshandleKeys->Get(0);
|
||||
JSMutableHandle<JSTaggedValue> handleKey(thread, key);
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
auto taggedKey = JSTaggedValue(jshandleKeys->Get(i));
|
||||
handleKey.Update(taggedKey);
|
||||
PropertyDescriptor currentDesc(thread);
|
||||
@ -1247,13 +1247,13 @@ bool JSObject::TestIntegrityLevel(JSThread *thread, const JSHandle<JSObject> &ob
|
||||
|
||||
JSHandle<TaggedArray> jshandleKeys = GetOwnPropertyKeys(thread, obj);
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false);
|
||||
array_size_t length = jshandleKeys->GetLength();
|
||||
uint32_t length = jshandleKeys->GetLength();
|
||||
if (length == 0) {
|
||||
return true;
|
||||
}
|
||||
auto key = jshandleKeys->Get(0);
|
||||
JSMutableHandle<JSTaggedValue> handleKey(thread, key);
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
auto taggedKey = JSTaggedValue(jshandleKeys->Get(i));
|
||||
handleKey.Update(taggedKey);
|
||||
PropertyDescriptor currentDesc(thread);
|
||||
@ -1278,7 +1278,7 @@ JSHandle<TaggedArray> JSObject::EnumerableOwnNames(JSThread *thread, const JSHan
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> keys;
|
||||
JSHandle<JSTaggedValue> tagObj(obj);
|
||||
array_size_t copyLength = 0;
|
||||
uint32_t copyLength = 0;
|
||||
// fast mode
|
||||
if (tagObj->IsJSObject() && !tagObj->IsTypedArray()) {
|
||||
uint32_t numOfKeys = obj->GetNumberOfKeys();
|
||||
@ -1307,10 +1307,10 @@ JSHandle<TaggedArray> JSObject::EnumerableOwnNames(JSThread *thread, const JSHan
|
||||
|
||||
keys = JSTaggedValue::GetOwnPropertyKeys(thread, tagObj);
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(TaggedArray, thread);
|
||||
array_size_t length = keys->GetLength();
|
||||
uint32_t length = keys->GetLength();
|
||||
|
||||
JSHandle<TaggedArray> names = factory->NewTaggedArray(length);
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
JSTaggedValue key(keys->Get(i));
|
||||
if (key.IsString()) {
|
||||
PropertyDescriptor desc(thread);
|
||||
@ -1338,7 +1338,7 @@ JSHandle<TaggedArray> JSObject::EnumerableOwnPropertyNames(JSThread *thread, con
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(TaggedArray, thread);
|
||||
|
||||
// 3. Let properties be a new empty List.
|
||||
array_size_t length = ownKeys->GetLength();
|
||||
uint32_t length = ownKeys->GetLength();
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> properties = factory->NewTaggedArray(length);
|
||||
|
||||
@ -1355,8 +1355,8 @@ JSHandle<TaggedArray> JSObject::EnumerableOwnPropertyNames(JSThread *thread, con
|
||||
// ii. Let entry be ! CreateArrayFromList(« key, value »).
|
||||
// iii. Append entry to properties.
|
||||
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
|
||||
array_size_t index = 0;
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
uint32_t index = 0;
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
key.Update(ownKeys->Get(thread, i));
|
||||
if (key->IsString()) {
|
||||
PropertyDescriptor desc(thread);
|
||||
|
@ -352,13 +352,9 @@ public:
|
||||
int32_t GetNativePointerFieldCount() const;
|
||||
void SetNativePointerFieldCount(int32_t count);
|
||||
|
||||
void VisitRangeSlot(const EcmaObjectRangeVisitor &visitor) const
|
||||
{
|
||||
TaggedObject *object = const_cast<TaggedObject *>(reinterpret_cast<const TaggedObject *>(this));
|
||||
visitor(object, ObjectSlot(ToUintPtr(this) + HASH_OFFSET), ObjectSlot(ToUintPtr(this) + SIZE));
|
||||
}
|
||||
DECL_VISIT_OBJECT(HASH_OFFSET, SIZE);
|
||||
|
||||
void VisitObjects([[maybe_unused]] const EcmaObjectRangeVisitor &visitor) const
|
||||
void VisitObjects(const EcmaObjectRangeVisitor &visitor)
|
||||
{
|
||||
// no field in this object
|
||||
VisitRangeSlot(visitor);
|
||||
@ -572,9 +568,9 @@ public:
|
||||
uint32_t GetNumberOfElements();
|
||||
|
||||
static JSHandle<TaggedArray> GetEnumElementKeys(JSThread *thread, const JSHandle<JSObject> &obj, int offset,
|
||||
uint32_t numOfElements, array_size_t *keys);
|
||||
uint32_t numOfElements, uint32_t *keys);
|
||||
static JSHandle<TaggedArray> GetAllEnumKeys(const JSThread *thread, const JSHandle<JSObject> &obj, int offset,
|
||||
uint32_t numOfKeys, array_size_t *keys);
|
||||
uint32_t numOfKeys, uint32_t *keys);
|
||||
|
||||
static void AddAccessor(JSThread *thread, const JSHandle<JSTaggedValue> &obj, const JSHandle<JSTaggedValue> &key,
|
||||
const JSHandle<AccessorData> &value, PropertyAttributes attr);
|
||||
|
@ -744,13 +744,13 @@ JSHandle<TaggedArray> JSProxy::OwnPropertyKeys(JSThread *thread, const JSHandle<
|
||||
// i.Append key as an element of targetNonconfigurableKeys.
|
||||
// d.Else,
|
||||
// i.Append key as an element of targetConfigurableKeys.
|
||||
array_size_t length = targetKeys->GetLength();
|
||||
uint32_t length = targetKeys->GetLength();
|
||||
JSHandle<TaggedArray> tgtCfigKeys = thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length);
|
||||
JSHandle<TaggedArray> tgtNoCfigKeys = thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length);
|
||||
|
||||
array_size_t cfigLength = 0;
|
||||
array_size_t noCfigLength = 0;
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
uint32_t cfigLength = 0;
|
||||
uint32_t noCfigLength = 0;
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
JSHandle<JSTaggedValue> targetKey(thread, targetKeys->Get(i));
|
||||
ASSERT(targetKey->IsStringOrSymbol());
|
||||
|
||||
@ -776,13 +776,13 @@ JSHandle<TaggedArray> JSProxy::OwnPropertyKeys(JSThread *thread, const JSHandle<
|
||||
// 20.Let uncheckedResultKeys be a new List which is a copy of trapResult.
|
||||
JSHandle<TaggedArray> uncheckFesKeys =
|
||||
thread->GetEcmaVM()->GetFactory()->CopyArray(trapRes, trapRes->GetLength(), trapRes->GetLength());
|
||||
array_size_t uncheckLength = uncheckFesKeys->GetLength();
|
||||
uint32_t uncheckLength = uncheckFesKeys->GetLength();
|
||||
|
||||
// 21.Repeat, for each key that is an element of targetNonconfigurableKeys,
|
||||
// a.If key is not an element of uncheckedResultKeys, throw a TypeError exception.
|
||||
// b.Remove key from uncheckedResultKeys
|
||||
for (array_size_t i = 0; i < noCfigLength; i++) {
|
||||
array_size_t idx = uncheckFesKeys->GetIdx(tgtNoCfigKeys->Get(i));
|
||||
for (uint32_t i = 0; i < noCfigLength; i++) {
|
||||
uint32_t idx = uncheckFesKeys->GetIdx(tgtNoCfigKeys->Get(i));
|
||||
if (idx == TaggedArray::MAX_ARRAY_INDEX) {
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "OwnPropertyKeys: key is not an element of uncheckedResultKeys",
|
||||
JSHandle<TaggedArray>(thread, JSTaggedValue::Exception()));
|
||||
@ -799,8 +799,8 @@ JSHandle<TaggedArray> JSProxy::OwnPropertyKeys(JSThread *thread, const JSHandle<
|
||||
// 23.Repeat, for each key that is an element of targetConfigurableKeys,
|
||||
// a.If key is not an element of uncheckedResultKeys, throw a TypeError exception.
|
||||
// b.Remove key from uncheckedResultKeys
|
||||
for (array_size_t i = 0; i < cfigLength; i++) {
|
||||
array_size_t idx = uncheckFesKeys->GetIdx(tgtCfigKeys->Get(i));
|
||||
for (uint32_t i = 0; i < cfigLength; i++) {
|
||||
uint32_t idx = uncheckFesKeys->GetIdx(tgtCfigKeys->Get(i));
|
||||
if (idx == TaggedArray::MAX_ARRAY_INDEX) {
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "OwnPropertyKeys: key is not an element of uncheckedResultKeys",
|
||||
JSHandle<TaggedArray>(thread, JSTaggedValue::Exception()));
|
||||
@ -846,7 +846,7 @@ JSTaggedValue JSProxy::CallInternal(JSThread *thread, const JSHandle<JSProxy> &p
|
||||
// 8.Let argArray be CreateArrayFromList(argumentsList).
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> taggedArray = factory->NewTaggedArray(argc);
|
||||
for (array_size_t index = 0; index < argc; ++index) {
|
||||
for (uint32_t index = 0; index < argc; ++index) {
|
||||
taggedArray->Set(thread, index, JSTaggedValue(argv[index]));
|
||||
}
|
||||
JSHandle<JSArray> arrHandle = JSArray::CreateArrayFromList(thread, taggedArray);
|
||||
@ -886,7 +886,7 @@ JSTaggedValue JSProxy::ConstructInternal(JSThread *thread, const JSHandle<JSProx
|
||||
// 8.Let argArray be CreateArrayFromList(argumentsList).
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> taggedArray = factory->NewTaggedArray(argc);
|
||||
for (array_size_t index = 0; index < argc; ++index) {
|
||||
for (uint32_t index = 0; index < argc; ++index) {
|
||||
taggedArray->Set(thread, index, JSTaggedValue(argv[index]));
|
||||
}
|
||||
JSHandle<JSArray> arrHandle = JSArray::CreateArrayFromList(thread, taggedArray);
|
||||
|
@ -28,16 +28,16 @@ namespace panda::ecmascript {
|
||||
JSTaggedValue JSStableArray::Push(JSHandle<JSArray> receiver, EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
JSThread *thread = argv->GetThread();
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
uint32_t oldLength = receiver->GetArrayLength();
|
||||
array_size_t newLength = argc + oldLength;
|
||||
uint32_t newLength = argc + oldLength;
|
||||
|
||||
TaggedArray *elements = TaggedArray::Cast(receiver->GetElements().GetTaggedObject());
|
||||
if (newLength > elements->GetLength()) {
|
||||
elements = *JSObject::GrowElementsCapacity(thread, JSHandle<JSObject>::Cast(receiver), newLength);
|
||||
}
|
||||
|
||||
for (array_size_t k = 0; k < argc; k++) {
|
||||
for (uint32_t k = 0; k < argc; k++) {
|
||||
JSHandle<JSTaggedValue> value = argv->GetCallArg(k);
|
||||
elements->Set(thread, oldLength + k, value.GetTaggedValue());
|
||||
}
|
||||
@ -56,8 +56,8 @@ JSTaggedValue JSStableArray::Pop(JSHandle<JSArray> receiver, EcmaRuntimeCallInfo
|
||||
}
|
||||
|
||||
TaggedArray *elements = TaggedArray::Cast(receiver->GetElements().GetTaggedObject());
|
||||
array_size_t capacity = elements->GetLength();
|
||||
array_size_t index = length - 1;
|
||||
uint32_t capacity = elements->GetLength();
|
||||
uint32_t index = length - 1;
|
||||
auto result = elements->Get(index);
|
||||
if (TaggedArray::ShouldTrim(thread, capacity, index)) {
|
||||
elements->Trim(thread, index);
|
||||
@ -73,7 +73,7 @@ JSTaggedValue JSStableArray::Splice(JSHandle<JSArray> receiver, EcmaRuntimeCallI
|
||||
{
|
||||
JSThread *thread = argv->GetThread();
|
||||
uint32_t len = receiver->GetArrayLength();
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
|
||||
JSHandle<JSObject> thisObjHandle(receiver);
|
||||
JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle, JSTaggedNumber(actualDeleteCount));
|
||||
@ -90,7 +90,7 @@ JSTaggedValue JSStableArray::Splice(JSHandle<JSArray> receiver, EcmaRuntimeCallI
|
||||
destElements = *JSObject::GrowElementsCapacity(thread, newArrayHandle, actualDeleteCount);
|
||||
}
|
||||
|
||||
for (array_size_t idx = 0; idx < actualDeleteCount; idx++) {
|
||||
for (uint32_t idx = 0; idx < actualDeleteCount; idx++) {
|
||||
destElements->Set(thread, idx, srcElementsHandle->Get(start + idx));
|
||||
}
|
||||
JSHandle<JSArray>::Cast(newArrayHandle)->SetArrayLength(thread, actualDeleteCount);
|
||||
@ -122,10 +122,10 @@ JSTaggedValue JSStableArray::Splice(JSHandle<JSArray> receiver, EcmaRuntimeCallI
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
}
|
||||
|
||||
array_size_t oldCapacity = srcElementsHandle->GetLength();
|
||||
array_size_t newCapacity = len - actualDeleteCount + insertCount;
|
||||
uint32_t oldCapacity = srcElementsHandle->GetLength();
|
||||
uint32_t newCapacity = len - actualDeleteCount + insertCount;
|
||||
if (insertCount < actualDeleteCount) {
|
||||
for (array_size_t idx = start; idx < len - actualDeleteCount; idx++) {
|
||||
for (uint32_t idx = start; idx < len - actualDeleteCount; idx++) {
|
||||
auto element = srcElementsHandle->Get(idx + actualDeleteCount);
|
||||
element = element.IsHole() ? JSTaggedValue::Undefined() : element;
|
||||
srcElementsHandle->Set(thread, idx + insertCount, element);
|
||||
@ -134,7 +134,7 @@ JSTaggedValue JSStableArray::Splice(JSHandle<JSArray> receiver, EcmaRuntimeCallI
|
||||
if (TaggedArray::ShouldTrim(thread, oldCapacity, newCapacity)) {
|
||||
srcElementsHandle->Trim(thread, newCapacity);
|
||||
} else {
|
||||
for (array_size_t idx = newCapacity; idx < len; idx++) {
|
||||
for (uint32_t idx = newCapacity; idx < len; idx++) {
|
||||
srcElementsHandle->Set(thread, idx, JSTaggedValue::Hole());
|
||||
}
|
||||
}
|
||||
@ -142,14 +142,14 @@ JSTaggedValue JSStableArray::Splice(JSHandle<JSArray> receiver, EcmaRuntimeCallI
|
||||
if (newCapacity > oldCapacity) {
|
||||
srcElementsHandle = JSObject::GrowElementsCapacity(thread, thisObjHandle, newCapacity);
|
||||
}
|
||||
for (array_size_t idx = len - actualDeleteCount; idx > start; idx--) {
|
||||
for (uint32_t idx = len - actualDeleteCount; idx > start; idx--) {
|
||||
auto element = srcElementsHandle->Get(idx + actualDeleteCount - 1);
|
||||
element = element.IsHole() ? JSTaggedValue::Undefined() : element;
|
||||
srcElementsHandle->Set(thread, idx + insertCount - 1, element);
|
||||
}
|
||||
}
|
||||
|
||||
for (array_size_t i = 2, idx = start; i < argc; i++, idx++) {
|
||||
for (uint32_t i = 2, idx = start; i < argc; i++, idx++) {
|
||||
srcElementsHandle->Set(thread, idx, argv->GetCallArg(i));
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ JSTaggedValue JSStableArray::Shift(JSHandle<JSArray> receiver, EcmaRuntimeCallIn
|
||||
|
||||
TaggedArray *elements = TaggedArray::Cast(receiver->GetElements().GetTaggedObject());
|
||||
auto result = elements->Get(0);
|
||||
for (array_size_t k = 1; k < length; k++) {
|
||||
for (uint32_t k = 1; k < length; k++) {
|
||||
auto kValue = elements->Get(k);
|
||||
if (kValue.IsHole()) {
|
||||
elements->Set(thread, k - 1, JSTaggedValue::Undefined());
|
||||
@ -178,8 +178,8 @@ JSTaggedValue JSStableArray::Shift(JSHandle<JSArray> receiver, EcmaRuntimeCallIn
|
||||
elements->Set(thread, k - 1, kValue);
|
||||
}
|
||||
}
|
||||
array_size_t capacity = elements->GetLength();
|
||||
array_size_t index = length - 1;
|
||||
uint32_t capacity = elements->GetLength();
|
||||
uint32_t index = length - 1;
|
||||
if (TaggedArray::ShouldTrim(thread, capacity, index)) {
|
||||
elements->Trim(thread, index);
|
||||
} else {
|
||||
@ -225,7 +225,7 @@ JSTaggedValue JSStableArray::Join(JSHandle<JSArray> receiver, EcmaRuntimeCallInf
|
||||
CVector<JSHandle<EcmaString>> vec;
|
||||
JSMutableHandle<JSTaggedValue> elementHandle(thread, JSTaggedValue::Undefined());
|
||||
const GlobalEnvConstants *globalConst = thread->GlobalConstants();
|
||||
for (array_size_t k = 0; k < length; k++) {
|
||||
for (uint32_t k = 0; k < length; k++) {
|
||||
JSTaggedValue element = elements->Get(k);
|
||||
if (!element.IsUndefinedOrNull() && !element.IsHole()) {
|
||||
if (!element.IsString()) {
|
||||
@ -248,7 +248,7 @@ JSTaggedValue JSStableArray::Join(JSHandle<JSArray> receiver, EcmaRuntimeCallInf
|
||||
auto newString = EcmaString::AllocStringObject(allocateLength, isOneByte, thread->GetEcmaVM());
|
||||
int current = 0;
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
for (array_size_t k = 0; k < length; k++) {
|
||||
for (uint32_t k = 0; k < length; k++) {
|
||||
if (k > 0) {
|
||||
if (sep >= 0) {
|
||||
newString->WriteData(static_cast<char>(sep), current);
|
||||
|
@ -883,15 +883,15 @@ inline bool JSTaggedValue::ToArrayLength(JSThread *thread, const JSHandle<JSTagg
|
||||
return true;
|
||||
}
|
||||
|
||||
inline array_size_t JSTaggedValue::GetArrayLength() const
|
||||
inline uint32_t JSTaggedValue::GetArrayLength() const
|
||||
{
|
||||
ASSERT(IsNumber());
|
||||
if (IsInt()) {
|
||||
return static_cast<array_size_t>(GetInt());
|
||||
return static_cast<uint32_t>(GetInt());
|
||||
}
|
||||
if (IsDouble()) {
|
||||
ASSERT(GetDouble() <= TaggedArray::MAX_ARRAY_INDEX);
|
||||
return static_cast<array_size_t>(GetDouble());
|
||||
return static_cast<uint32_t>(GetDouble());
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ public:
|
||||
static bool ToArrayLength(JSThread *thread, const JSHandle<JSTaggedValue> &tagged, uint32_t *output);
|
||||
static bool ToElementIndex(JSTaggedValue key, uint32_t *output);
|
||||
static bool StringToElementIndex(JSTaggedValue key, uint32_t *output);
|
||||
array_size_t GetArrayLength() const;
|
||||
uint32_t GetArrayLength() const;
|
||||
|
||||
// ecma6 7.2 Testing and Comparison Operations
|
||||
bool IsCallable() const;
|
||||
|
@ -256,16 +256,16 @@ JSHandle<TaggedArray> JSTypedArray::OwnPropertyKeys(JSThread *thread, const JSHa
|
||||
// 3. Let len be the value of O’s [[ArrayLength]] internal slot.
|
||||
JSHandle<JSObject> arrayObj(typedarray);
|
||||
JSHandle<TaggedArray> objKeys = JSObject::GetOwnPropertyKeys(thread, arrayObj);
|
||||
array_size_t objKeysLen = objKeys->GetLength();
|
||||
array_size_t bufferKeysLen = TypedArrayHelper::GetArrayLength(thread, arrayObj);
|
||||
array_size_t length = objKeysLen + bufferKeysLen;
|
||||
uint32_t objKeysLen = objKeys->GetLength();
|
||||
uint32_t bufferKeysLen = TypedArrayHelper::GetArrayLength(thread, arrayObj);
|
||||
uint32_t length = objKeysLen + bufferKeysLen;
|
||||
JSHandle<TaggedArray> nameList = factory->NewTaggedArray(length);
|
||||
|
||||
// 4. For each integer i starting with 0 such that i < len, in ascending order,
|
||||
// a. Add ToString(i) as the last element of keys.
|
||||
array_size_t copyLength = 0;
|
||||
uint32_t copyLength = 0;
|
||||
JSMutableHandle<JSTaggedValue> tKey(thread, JSTaggedValue::Undefined());
|
||||
for (array_size_t k = 0; k < bufferKeysLen; k++) {
|
||||
for (uint32_t k = 0; k < bufferKeysLen; k++) {
|
||||
tKey.Update(JSTaggedValue(k));
|
||||
JSHandle<JSTaggedValue> sKey(JSTaggedValue::ToString(thread, tKey));
|
||||
nameList->Set(thread, copyLength, sKey.GetTaggedValue());
|
||||
@ -275,7 +275,7 @@ JSHandle<TaggedArray> JSTypedArray::OwnPropertyKeys(JSThread *thread, const JSHa
|
||||
// 5. For each own property key P of O such that Type(P) is String and P is not an integer index, in
|
||||
// property creation order
|
||||
// a. Add P as the last element of keys.
|
||||
for (array_size_t i = 0; i < objKeysLen; i++) {
|
||||
for (uint32_t i = 0; i < objKeysLen; i++) {
|
||||
JSTaggedValue key = objKeys->Get(i);
|
||||
if (JSTaggedValue(key).IsString()) {
|
||||
nameList->Set(thread, copyLength, key);
|
||||
@ -285,7 +285,7 @@ JSHandle<TaggedArray> JSTypedArray::OwnPropertyKeys(JSThread *thread, const JSHa
|
||||
|
||||
// 6. For each own property key P of O such that Type(P) is Symbol, in property creation order
|
||||
// a. Add P as the last element of keys.
|
||||
for (array_size_t i = 0; i < objKeysLen; i++) {
|
||||
for (uint32_t i = 0; i < objKeysLen; i++) {
|
||||
JSTaggedValue key = objKeys->Get(i);
|
||||
if (JSTaggedValue(key).IsSymbol()) {
|
||||
nameList->Set(thread, copyLength, key);
|
||||
|
@ -36,12 +36,12 @@ inline void LayoutInfo::SetNumberOfElements(const JSThread *thread, int properti
|
||||
return TaggedArray::Set(thread, NUMBER_OF_PROPERTIES_INDEX, JSTaggedValue(properties));
|
||||
}
|
||||
|
||||
inline array_size_t LayoutInfo::GetKeyIndex(int index) const
|
||||
inline uint32_t LayoutInfo::GetKeyIndex(int index) const
|
||||
{
|
||||
return ELEMENTS_START_INDEX + (static_cast<uint32_t>(index) << 1U);
|
||||
}
|
||||
|
||||
inline array_size_t LayoutInfo::GetAttrIndex(int index) const
|
||||
inline uint32_t LayoutInfo::GetAttrIndex(int index) const
|
||||
{
|
||||
return ELEMENTS_START_INDEX + (static_cast<uint32_t>(index) << 1U) + 1;
|
||||
}
|
||||
@ -49,14 +49,14 @@ inline array_size_t LayoutInfo::GetAttrIndex(int index) const
|
||||
inline void LayoutInfo::SetPropertyInit(const JSThread *thread, int index, const JSTaggedValue &key,
|
||||
const PropertyAttributes &attr)
|
||||
{
|
||||
array_size_t fixed_idx = GetKeyIndex(index);
|
||||
uint32_t fixed_idx = GetKeyIndex(index);
|
||||
TaggedArray::Set(thread, fixed_idx, key);
|
||||
TaggedArray::Set(thread, fixed_idx + 1, attr.GetNormalTagged());
|
||||
}
|
||||
|
||||
inline void LayoutInfo::SetNormalAttr(const JSThread *thread, int index, const PropertyAttributes &attr)
|
||||
{
|
||||
array_size_t fixed_idx = GetAttrIndex(index);
|
||||
uint32_t fixed_idx = GetAttrIndex(index);
|
||||
PropertyAttributes oldAttr(TaggedArray::Get(fixed_idx));
|
||||
oldAttr.SetNormalAttr(attr.GetNormalAttr());
|
||||
TaggedArray::Set(thread, fixed_idx, oldAttr.GetTaggedValue());
|
||||
@ -64,30 +64,30 @@ inline void LayoutInfo::SetNormalAttr(const JSThread *thread, int index, const P
|
||||
|
||||
inline JSTaggedValue LayoutInfo::GetKey(int index) const
|
||||
{
|
||||
array_size_t fixed_idx = GetKeyIndex(index);
|
||||
uint32_t fixed_idx = GetKeyIndex(index);
|
||||
return TaggedArray::Get(fixed_idx);
|
||||
}
|
||||
|
||||
inline PropertyAttributes LayoutInfo::GetAttr(int index) const
|
||||
{
|
||||
array_size_t fixed_idx = GetAttrIndex(index);
|
||||
uint32_t fixed_idx = GetAttrIndex(index);
|
||||
return PropertyAttributes(TaggedArray::Get(fixed_idx));
|
||||
}
|
||||
|
||||
inline JSTaggedValue LayoutInfo::GetSortedKey(int index) const
|
||||
{
|
||||
array_size_t fixed_idx = GetSortedIndex(index);
|
||||
uint32_t fixed_idx = GetSortedIndex(index);
|
||||
return GetKey(fixed_idx);
|
||||
}
|
||||
|
||||
inline array_size_t LayoutInfo::GetSortedIndex(int index) const
|
||||
inline uint32_t LayoutInfo::GetSortedIndex(int index) const
|
||||
{
|
||||
return GetAttr(index).GetSortedIndex();
|
||||
}
|
||||
|
||||
inline void LayoutInfo::SetSortedIndex(const JSThread *thread, int index, int sortedIndex)
|
||||
{
|
||||
array_size_t fixed_idx = GetAttrIndex(index);
|
||||
uint32_t fixed_idx = GetAttrIndex(index);
|
||||
PropertyAttributes attr(TaggedArray::Get(fixed_idx));
|
||||
attr.SetSortedIndex(sortedIndex);
|
||||
TaggedArray::Set(thread, fixed_idx, attr.GetTaggedValue());
|
||||
|
@ -83,7 +83,7 @@ void LayoutInfo::GetAllKeys(const JSThread *thread, int end, std::vector<JSTagge
|
||||
}
|
||||
|
||||
void LayoutInfo::GetAllEnumKeys(const JSThread *thread, int end, int offset, TaggedArray *keyArray,
|
||||
array_size_t *keys)
|
||||
uint32_t *keys)
|
||||
{
|
||||
ASSERT(end <= NumberOfElements());
|
||||
ASSERT_PRINT(offset + end <= static_cast<int>(keyArray->GetLength()),
|
||||
@ -102,7 +102,7 @@ void LayoutInfo::GetAllEnumKeys(const JSThread *thread, int end, int offset, Tag
|
||||
}
|
||||
|
||||
void LayoutInfo::GetAllNames(const JSThread *thread, int end, const JSHandle<TaggedArray> &keyArray,
|
||||
array_size_t *length)
|
||||
uint32_t *length)
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
int arrayIndex = 0;
|
||||
|
@ -42,37 +42,37 @@ public:
|
||||
int GetPropertiesCapacity() const;
|
||||
int NumberOfElements() const;
|
||||
void SetNumberOfElements(const JSThread *thread, int properties);
|
||||
array_size_t GetKeyIndex(int index) const;
|
||||
array_size_t GetAttrIndex(int index) const;
|
||||
uint32_t GetKeyIndex(int index) const;
|
||||
uint32_t GetAttrIndex(int index) const;
|
||||
void SetPropertyInit(const JSThread *thread, int index, const JSTaggedValue &key, const PropertyAttributes &attr);
|
||||
void SetKey(const JSThread *thread, int index, const JSTaggedValue &key);
|
||||
void SetNormalAttr(const JSThread *thread, int index, const PropertyAttributes &attr);
|
||||
JSTaggedValue GetKey(int index) const;
|
||||
PropertyAttributes GetAttr(int index) const;
|
||||
JSTaggedValue GetSortedKey(int index) const;
|
||||
array_size_t GetSortedIndex(int index) const;
|
||||
uint32_t GetSortedIndex(int index) const;
|
||||
void SetSortedIndex(const JSThread *thread, int index, int sortedIndex);
|
||||
void AddKey(const JSThread *thread, int index, const JSTaggedValue &key, const PropertyAttributes &attr);
|
||||
|
||||
inline array_size_t GetLength() const
|
||||
inline uint32_t GetLength() const
|
||||
{
|
||||
return TaggedArray::GetLength();
|
||||
}
|
||||
|
||||
inline Properties *GetProperties() const
|
||||
{
|
||||
return reinterpret_cast<Properties *>(reinterpret_cast<uintptr_t>(this) + TaggedArray::GetDataOffset() +
|
||||
return reinterpret_cast<Properties *>(reinterpret_cast<uintptr_t>(this) + TaggedArray::DATA_OFFSET +
|
||||
ELEMENTS_START_INDEX * JSTaggedValue::TaggedTypeSize());
|
||||
}
|
||||
|
||||
static inline array_size_t ComputeArrayLength(array_size_t properties_number)
|
||||
static inline uint32_t ComputeArrayLength(uint32_t properties_number)
|
||||
{
|
||||
return (properties_number << 1U) + ELEMENTS_START_INDEX;
|
||||
}
|
||||
|
||||
static inline array_size_t ComputeGrowCapacity(uint32_t old_capacity)
|
||||
static inline uint32_t ComputeGrowCapacity(uint32_t old_capacity)
|
||||
{
|
||||
array_size_t new_capacity = old_capacity + MIN_PROPERTIES_LENGTH;
|
||||
uint32_t new_capacity = old_capacity + MIN_PROPERTIES_LENGTH;
|
||||
return new_capacity > MAX_PROPERTIES_LENGTH ? MAX_PROPERTIES_LENGTH : new_capacity;
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@ public:
|
||||
int BinarySearch(JSTaggedValue key, int propertiesNumber);
|
||||
void GetAllKeys(const JSThread *thread, int end, int offset, TaggedArray *keyArray);
|
||||
void GetAllKeys(const JSThread *thread, int end, std::vector<JSTaggedValue> &keyVector);
|
||||
void GetAllEnumKeys(const JSThread *thread, int end, int offset, TaggedArray *keyArray, array_size_t *keys);
|
||||
void GetAllNames(const JSThread *thread, int end, const JSHandle<TaggedArray> &keyArray, array_size_t *length);
|
||||
void GetAllEnumKeys(const JSThread *thread, int end, int offset, TaggedArray *keyArray, uint32_t *keys);
|
||||
void GetAllNames(const JSThread *thread, int end, const JSHandle<TaggedArray> &keyArray, uint32_t *length);
|
||||
|
||||
DECL_DUMP()
|
||||
};
|
||||
|
@ -21,8 +21,8 @@
|
||||
namespace panda::ecmascript {
|
||||
class LexicalEnv : public TaggedArray {
|
||||
public:
|
||||
static constexpr array_size_t PARENT_ENV_INDEX = 0;
|
||||
static constexpr array_size_t RESERVED_ENV_LENGTH = 1;
|
||||
static constexpr uint32_t PARENT_ENV_INDEX = 0;
|
||||
static constexpr uint32_t RESERVED_ENV_LENGTH = 1;
|
||||
|
||||
static LexicalEnv *Cast(ObjectHeader *object)
|
||||
{
|
||||
|
@ -39,8 +39,8 @@ void LiteralDataExtractor::ExtractObjectDatas(JSThread *thread, const panda_file
|
||||
uint32_t num = lda.GetLiteralValsNum(index) / 2; // 2: half
|
||||
elements.Update(factory->NewTaggedArray(num).GetTaggedValue());
|
||||
properties.Update(factory->NewTaggedArray(num).GetTaggedValue());
|
||||
array_size_t epos = 0;
|
||||
array_size_t ppos = 0;
|
||||
uint32_t epos = 0;
|
||||
uint32_t ppos = 0;
|
||||
const uint8_t pairSize = 2;
|
||||
uint32_t methodId;
|
||||
FunctionKind kind;
|
||||
@ -125,7 +125,7 @@ JSHandle<TaggedArray> LiteralDataExtractor::GetDatasIgnoreType(JSThread *thread,
|
||||
|
||||
uint32_t num = lda.GetLiteralValsNum(index) / 2; // 2: half
|
||||
JSHandle<TaggedArray> literals = factory->NewTaggedArray(num);
|
||||
array_size_t pos = 0;
|
||||
uint32_t pos = 0;
|
||||
uint32_t methodId;
|
||||
FunctionKind kind;
|
||||
lda.EnumerateLiteralVals(
|
||||
@ -186,7 +186,7 @@ JSHandle<TaggedArray> LiteralDataExtractor::GetDatasIgnoreType(JSThread *thread,
|
||||
if (tag != LiteralTag::METHOD && tag != LiteralTag::GENERATORMETHOD) {
|
||||
literals->Set(thread, pos++, jt);
|
||||
} else {
|
||||
array_size_t oldLength = literals->GetLength();
|
||||
uint32_t oldLength = literals->GetLength();
|
||||
literals->Trim(thread, oldLength - 1);
|
||||
}
|
||||
});
|
||||
|
@ -1281,7 +1281,7 @@ Local<ArrayBufferRef> TypedArrayRef::GetArrayBuffer(const EcmaVM *vm)
|
||||
JSHandle<JSArrayBuffer> arrayBuffer(JSNApiHelper::ToJSHandle(buffer)); \
|
||||
ecmascript::InternalCallParams *argv = thread->GetInternalCallParams(); \
|
||||
argv->MakeArgv(arrayBuffer.GetTaggedValue(), JSTaggedValue(byteOffset), JSTaggedValue(length)); \
|
||||
array_size_t argc = 3; \
|
||||
uint32_t argc = 3; \
|
||||
JSTaggedValue result = JSFunction::Construct(thread, func, argc, argv->GetArgv(), func); \
|
||||
RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Exception(vm)); \
|
||||
JSHandle<JSTaggedValue> resultHandle(thread, result); \
|
||||
@ -1439,8 +1439,8 @@ JSTaggedValue Callback::RegisterCallback(ecmascript::EcmaRuntimeCallInfo *info)
|
||||
|
||||
// arguments
|
||||
std::vector<Local<JSValueRef>> arguments;
|
||||
array_size_t length = info->GetArgsNumber();
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
uint32_t length = info->GetArgsNumber();
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
arguments.emplace_back(JSNApiHelper::ToLocal<JSValueRef>(BuiltinsBase::GetCallArg(info, i)));
|
||||
}
|
||||
|
||||
@ -1491,8 +1491,8 @@ JSTaggedValue Callback::RegisterCallbackWithProperty(ecmascript::EcmaRuntimeCall
|
||||
|
||||
// arguments
|
||||
std::vector<Local<JSValueRef>> arguments;
|
||||
array_size_t length = info->GetArgsNumber();
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
uint32_t length = info->GetArgsNumber();
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
arguments.emplace_back(JSNApiHelper::ToLocal<JSValueRef>(BuiltinsBase::GetCallArg(info, i)));
|
||||
}
|
||||
|
||||
@ -1547,8 +1547,8 @@ JSTaggedValue Callback::RegisterCallbackWithNewTarget(ecmascript::EcmaRuntimeCal
|
||||
|
||||
// arguments
|
||||
std::vector<Local<JSValueRef>> arguments;
|
||||
array_size_t length = info->GetArgsNumber();
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
uint32_t length = info->GetArgsNumber();
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
arguments.emplace_back(JSNApiHelper::ToLocal<JSValueRef>(BuiltinsBase::GetCallArg(info, i)));
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ JSHandle<JSObject> ObjectFactory::NewJSObject(const JSHandle<JSHClass> &jshclass
|
||||
|
||||
JSHandle<TaggedArray> ObjectFactory::CloneProperties(const JSHandle<TaggedArray> &old)
|
||||
{
|
||||
array_size_t newLength = old->GetLength();
|
||||
uint32_t newLength = old->GetLength();
|
||||
if (newLength == 0) {
|
||||
return EmptyArray();
|
||||
}
|
||||
@ -320,7 +320,7 @@ JSHandle<TaggedArray> ObjectFactory::CloneProperties(const JSHandle<TaggedArray>
|
||||
JSHandle<TaggedArray> newArray(thread_, header);
|
||||
newArray->SetLength(newLength);
|
||||
|
||||
for (array_size_t i = 0; i < newLength; i++) {
|
||||
for (uint32_t i = 0; i < newLength; i++) {
|
||||
JSTaggedValue value = old->Get(i);
|
||||
newArray->Set(thread_, i, value);
|
||||
}
|
||||
@ -374,14 +374,14 @@ JSHandle<TaggedArray> ObjectFactory::CloneProperties(const JSHandle<TaggedArray>
|
||||
const JSHandle<JSTaggedValue> &env, const JSHandle<JSObject> &obj,
|
||||
const JSHandle<JSTaggedValue> &constpool)
|
||||
{
|
||||
array_size_t newLength = old->GetLength();
|
||||
uint32_t newLength = old->GetLength();
|
||||
if (newLength == 0) {
|
||||
return EmptyArray();
|
||||
}
|
||||
NewObjectHook();
|
||||
JSHandle<TaggedArray> newArray = NewTaggedArray(newLength);
|
||||
|
||||
for (array_size_t i = 0; i < newLength; i++) {
|
||||
for (uint32_t i = 0; i < newLength; i++) {
|
||||
JSTaggedValue value = old->Get(i);
|
||||
if (!value.IsJSFunction()) {
|
||||
newArray->Set(thread_, i, value);
|
||||
@ -1479,13 +1479,13 @@ JSHandle<JSRealm> ObjectFactory::NewJSRealm()
|
||||
JSHandle<TaggedArray> ObjectFactory::NewEmptyArray()
|
||||
{
|
||||
NewObjectHook();
|
||||
auto header = heapHelper_.AllocateNonMovableOrHugeObject(arrayClass_, sizeof(TaggedArray));
|
||||
auto header = heapHelper_.AllocateNonMovableOrHugeObject(arrayClass_, TaggedArray::SIZE);
|
||||
JSHandle<TaggedArray> array(thread_, header);
|
||||
array->SetLength(0);
|
||||
return array;
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> ObjectFactory::NewTaggedArray(array_size_t length, JSTaggedValue initVal, bool nonMovable)
|
||||
JSHandle<TaggedArray> ObjectFactory::NewTaggedArray(uint32_t length, JSTaggedValue initVal, bool nonMovable)
|
||||
{
|
||||
if (nonMovable) {
|
||||
return NewTaggedArray(length, initVal, MemSpaceType::NON_MOVABLE);
|
||||
@ -1493,7 +1493,7 @@ JSHandle<TaggedArray> ObjectFactory::NewTaggedArray(array_size_t length, JSTagge
|
||||
return NewTaggedArray(length, initVal, MemSpaceType::SEMI_SPACE);
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> ObjectFactory::NewTaggedArray(array_size_t length, JSTaggedValue initVal, MemSpaceType spaceType)
|
||||
JSHandle<TaggedArray> ObjectFactory::NewTaggedArray(uint32_t length, JSTaggedValue initVal, MemSpaceType spaceType)
|
||||
{
|
||||
NewObjectHook();
|
||||
if (length == 0) {
|
||||
@ -1521,7 +1521,7 @@ JSHandle<TaggedArray> ObjectFactory::NewTaggedArray(array_size_t length, JSTagge
|
||||
return array;
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> ObjectFactory::NewTaggedArray(array_size_t length, JSTaggedValue initVal)
|
||||
JSHandle<TaggedArray> ObjectFactory::NewTaggedArray(uint32_t length, JSTaggedValue initVal)
|
||||
{
|
||||
NewObjectHook();
|
||||
if (length == 0) {
|
||||
@ -1535,7 +1535,7 @@ JSHandle<TaggedArray> ObjectFactory::NewTaggedArray(array_size_t length, JSTagge
|
||||
return array;
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> ObjectFactory::NewDictionaryArray(array_size_t length)
|
||||
JSHandle<TaggedArray> ObjectFactory::NewDictionaryArray(uint32_t length)
|
||||
{
|
||||
NewObjectHook();
|
||||
ASSERT(length > 0);
|
||||
@ -1548,7 +1548,7 @@ JSHandle<TaggedArray> ObjectFactory::NewDictionaryArray(array_size_t length)
|
||||
return array;
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> ObjectFactory::ExtendArray(const JSHandle<TaggedArray> &old, array_size_t length,
|
||||
JSHandle<TaggedArray> ObjectFactory::ExtendArray(const JSHandle<TaggedArray> &old, uint32_t length,
|
||||
JSTaggedValue initVal)
|
||||
{
|
||||
ASSERT(length > old->GetLength());
|
||||
@ -1558,26 +1558,26 @@ JSHandle<TaggedArray> ObjectFactory::ExtendArray(const JSHandle<TaggedArray> &ol
|
||||
JSHandle<TaggedArray> newArray(thread_, header);
|
||||
newArray->SetLength(length);
|
||||
|
||||
array_size_t oldLength = old->GetLength();
|
||||
for (array_size_t i = 0; i < oldLength; i++) {
|
||||
uint32_t oldLength = old->GetLength();
|
||||
for (uint32_t i = 0; i < oldLength; i++) {
|
||||
JSTaggedValue value = old->Get(i);
|
||||
newArray->Set(thread_, i, value);
|
||||
}
|
||||
|
||||
for (array_size_t i = oldLength; i < length; i++) {
|
||||
for (uint32_t i = oldLength; i < length; i++) {
|
||||
newArray->Set(thread_, i, initVal);
|
||||
}
|
||||
|
||||
return newArray;
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> ObjectFactory::CopyPartArray(const JSHandle<TaggedArray> &old, array_size_t start,
|
||||
array_size_t end)
|
||||
JSHandle<TaggedArray> ObjectFactory::CopyPartArray(const JSHandle<TaggedArray> &old, uint32_t start,
|
||||
uint32_t end)
|
||||
{
|
||||
ASSERT(start <= end);
|
||||
ASSERT(end <= old->GetLength());
|
||||
|
||||
array_size_t newLength = end - start;
|
||||
uint32_t newLength = end - start;
|
||||
if (newLength == 0) {
|
||||
return EmptyArray();
|
||||
}
|
||||
@ -1588,7 +1588,7 @@ JSHandle<TaggedArray> ObjectFactory::CopyPartArray(const JSHandle<TaggedArray> &
|
||||
JSHandle<TaggedArray> newArray(thread_, header);
|
||||
newArray->SetLength(newLength);
|
||||
|
||||
for (array_size_t i = 0; i < newLength; i++) {
|
||||
for (uint32_t i = 0; i < newLength; i++) {
|
||||
JSTaggedValue value = old->Get(i + start);
|
||||
if (value.IsHole()) {
|
||||
break;
|
||||
@ -1599,7 +1599,7 @@ JSHandle<TaggedArray> ObjectFactory::CopyPartArray(const JSHandle<TaggedArray> &
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> ObjectFactory::CopyArray(const JSHandle<TaggedArray> &old,
|
||||
[[maybe_unused]] array_size_t oldLength, array_size_t newLength,
|
||||
[[maybe_unused]] uint32_t oldLength, uint32_t newLength,
|
||||
JSTaggedValue initVal)
|
||||
{
|
||||
if (newLength == 0) {
|
||||
@ -1615,7 +1615,7 @@ JSHandle<TaggedArray> ObjectFactory::CopyArray(const JSHandle<TaggedArray> &old,
|
||||
JSHandle<TaggedArray> newArray(thread_, header);
|
||||
newArray->SetLength(newLength);
|
||||
|
||||
for (array_size_t i = 0; i < newLength; i++) {
|
||||
for (uint32_t i = 0; i < newLength; i++) {
|
||||
JSTaggedValue value = old->Get(i);
|
||||
newArray->Set(thread_, i, value);
|
||||
}
|
||||
@ -1811,9 +1811,9 @@ void ObjectFactory::NewObjectHook() const
|
||||
#endif
|
||||
}
|
||||
|
||||
JSHandle<TaggedQueue> ObjectFactory::NewTaggedQueue(array_size_t length)
|
||||
JSHandle<TaggedQueue> ObjectFactory::NewTaggedQueue(uint32_t length)
|
||||
{
|
||||
array_size_t queueLength = TaggedQueue::QueueToArrayIndex(length);
|
||||
uint32_t queueLength = TaggedQueue::QueueToArrayIndex(length);
|
||||
auto queue = JSHandle<TaggedQueue>::Cast(NewTaggedArray(queueLength, JSTaggedValue::Hole()));
|
||||
queue->SetStart(thread_, JSTaggedValue(0)); // equal to 0 when add 1.
|
||||
queue->SetEnd(thread_, JSTaggedValue(0));
|
||||
|
@ -219,10 +219,10 @@ public:
|
||||
|
||||
JSHandle<JSPrimitiveRef> NewJSString(const JSHandle<JSTaggedValue> &str);
|
||||
|
||||
JSHandle<TaggedArray> NewTaggedArray(array_size_t length, JSTaggedValue initVal = JSTaggedValue::Hole());
|
||||
JSHandle<TaggedArray> NewTaggedArray(array_size_t length, JSTaggedValue initVal, bool nonMovable);
|
||||
JSHandle<TaggedArray> NewTaggedArray(array_size_t length, JSTaggedValue initVal, MemSpaceType spaceType);
|
||||
JSHandle<TaggedArray> NewDictionaryArray(array_size_t length);
|
||||
JSHandle<TaggedArray> NewTaggedArray(uint32_t length, JSTaggedValue initVal = JSTaggedValue::Hole());
|
||||
JSHandle<TaggedArray> NewTaggedArray(uint32_t length, JSTaggedValue initVal, bool nonMovable);
|
||||
JSHandle<TaggedArray> NewTaggedArray(uint32_t length, JSTaggedValue initVal, MemSpaceType spaceType);
|
||||
JSHandle<TaggedArray> NewDictionaryArray(uint32_t length);
|
||||
JSHandle<JSForInIterator> NewJSForinIterator(const JSHandle<JSTaggedValue> &obj);
|
||||
|
||||
JSHandle<PropertyBox> NewPropertyBox(const JSHandle<JSTaggedValue> &name);
|
||||
@ -232,10 +232,10 @@ public:
|
||||
JSHandle<ProtoChangeDetails> NewProtoChangeDetails();
|
||||
|
||||
// use for copy properties keys's array to another array
|
||||
JSHandle<TaggedArray> ExtendArray(const JSHandle<TaggedArray> &old, array_size_t length,
|
||||
JSHandle<TaggedArray> ExtendArray(const JSHandle<TaggedArray> &old, uint32_t length,
|
||||
JSTaggedValue initVal = JSTaggedValue::Hole());
|
||||
JSHandle<TaggedArray> CopyPartArray(const JSHandle<TaggedArray> &old, array_size_t start, array_size_t end);
|
||||
JSHandle<TaggedArray> CopyArray(const JSHandle<TaggedArray> &old, array_size_t oldLength, array_size_t newLength,
|
||||
JSHandle<TaggedArray> CopyPartArray(const JSHandle<TaggedArray> &old, uint32_t start, uint32_t end);
|
||||
JSHandle<TaggedArray> CopyArray(const JSHandle<TaggedArray> &old, uint32_t oldLength, uint32_t newLength,
|
||||
JSTaggedValue initVal = JSTaggedValue::Hole());
|
||||
JSHandle<TaggedArray> CloneProperties(const JSHandle<TaggedArray> &old);
|
||||
JSHandle<TaggedArray> CloneProperties(const JSHandle<TaggedArray> &old, const JSHandle<JSTaggedValue> &env,
|
||||
@ -262,7 +262,7 @@ public:
|
||||
|
||||
void InitializeExtraProperties(const JSHandle<JSHClass> &dynclass, TaggedObject *obj, int inobjPropCount);
|
||||
|
||||
JSHandle<TaggedQueue> NewTaggedQueue(array_size_t length);
|
||||
JSHandle<TaggedQueue> NewTaggedQueue(uint32_t length);
|
||||
|
||||
JSHandle<TaggedQueue> GetEmptyTaggedQueue() const;
|
||||
|
||||
|
@ -914,10 +914,10 @@ void SnapShotSerialize::DynArraySerialize(TaggedObject *objectHeader, uintptr_t
|
||||
CQueue<TaggedObject *> *queue, std::unordered_map<uint64_t, SlotBit> *data)
|
||||
{
|
||||
auto arrayObject = reinterpret_cast<TaggedArray *>(objectHeader);
|
||||
size_t beginOffset = TaggedArray::GetDataOffset();
|
||||
size_t beginOffset = TaggedArray::DATA_OFFSET;
|
||||
auto arrayLength = arrayObject->GetLength();
|
||||
uintptr_t startAddr = ToUintPtr(objectHeader) + beginOffset;
|
||||
for (array_size_t i = 0; i < arrayLength; i++) {
|
||||
for (uint32_t i = 0; i < arrayLength; i++) {
|
||||
auto fieldAddr = reinterpret_cast<JSTaggedType *>(startAddr + i * TAGGED_SIZE);
|
||||
SetObjectSlotField(snapshotObj, beginOffset + i * TAGGED_SIZE, HandleTaggedField(fieldAddr, queue, data));
|
||||
}
|
||||
@ -930,9 +930,9 @@ void SnapShotSerialize::DynArrayDeserialize(uint64_t *objectHeader)
|
||||
DeserializeHandleClassWord(object);
|
||||
|
||||
auto arrayLength = object->GetLength();
|
||||
size_t dataOffset = TaggedArray::GetDataOffset();
|
||||
size_t dataOffset = TaggedArray::DATA_OFFSET;
|
||||
uintptr_t startAddr = ToUintPtr(objectHeader) + dataOffset;
|
||||
for (array_size_t i = 0; i < arrayLength; i++) {
|
||||
for (uint32_t i = 0; i < arrayLength; i++) {
|
||||
auto fieldAddr = reinterpret_cast<uint64_t *>(startAddr + i * TAGGED_SIZE);
|
||||
DeserializeHandleTaggedField(fieldAddr);
|
||||
}
|
||||
|
@ -21,12 +21,7 @@
|
||||
#include "ecmascript/tagged_array.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
inline array_size_t TaggedArray::GetLength() const
|
||||
{
|
||||
return Barriers::GetDynValue<array_size_t>(this, TaggedArray::GetLengthOffset());
|
||||
}
|
||||
|
||||
inline JSTaggedValue TaggedArray::Get(array_size_t idx) const
|
||||
inline JSTaggedValue TaggedArray::Get(uint32_t idx) const
|
||||
{
|
||||
ASSERT(idx < GetLength());
|
||||
// Note: Here we can't statically decide the element type is a primitive or heap object, especially for
|
||||
@ -36,16 +31,16 @@ inline JSTaggedValue TaggedArray::Get(array_size_t idx) const
|
||||
return JSTaggedValue(Barriers::GetDynValue<JSTaggedType>(GetData(), offset));
|
||||
}
|
||||
|
||||
inline JSTaggedValue TaggedArray::Get([[maybe_unused]] const JSThread *thread, array_size_t idx) const
|
||||
inline JSTaggedValue TaggedArray::Get([[maybe_unused]] const JSThread *thread, uint32_t idx) const
|
||||
{
|
||||
return Get(idx);
|
||||
}
|
||||
|
||||
inline array_size_t TaggedArray::GetIdx(const JSTaggedValue &value) const
|
||||
inline uint32_t TaggedArray::GetIdx(const JSTaggedValue &value) const
|
||||
{
|
||||
array_size_t length = GetLength();
|
||||
uint32_t length = GetLength();
|
||||
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
if (JSTaggedValue::SameValue(Get(i), value)) {
|
||||
return i;
|
||||
}
|
||||
@ -54,7 +49,7 @@ inline array_size_t TaggedArray::GetIdx(const JSTaggedValue &value) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void TaggedArray::Set(const JSThread *thread, array_size_t idx, const JSHandle<T> &value)
|
||||
inline void TaggedArray::Set(const JSThread *thread, uint32_t idx, const JSHandle<T> &value)
|
||||
{
|
||||
ASSERT(idx < GetLength());
|
||||
size_t offset = JSTaggedValue::TaggedTypeSize() * idx;
|
||||
@ -67,7 +62,7 @@ inline void TaggedArray::Set(const JSThread *thread, array_size_t idx, const JSH
|
||||
}
|
||||
}
|
||||
|
||||
inline void TaggedArray::Set(const JSThread *thread, array_size_t idx, const JSTaggedValue &value)
|
||||
inline void TaggedArray::Set(const JSThread *thread, uint32_t idx, const JSTaggedValue &value)
|
||||
{
|
||||
ASSERT(idx < GetLength());
|
||||
size_t offset = JSTaggedValue::TaggedTypeSize() * idx;
|
||||
@ -83,12 +78,12 @@ inline void TaggedArray::Set(const JSThread *thread, array_size_t idx, const JST
|
||||
JSHandle<TaggedArray> TaggedArray::Append(const JSThread *thread, const JSHandle<TaggedArray> &first,
|
||||
const JSHandle<TaggedArray> &second)
|
||||
{
|
||||
array_size_t firstLength = first->GetLength();
|
||||
array_size_t secondLength = second->GetLength();
|
||||
array_size_t length = firstLength + secondLength;
|
||||
uint32_t firstLength = first->GetLength();
|
||||
uint32_t secondLength = second->GetLength();
|
||||
uint32_t length = firstLength + secondLength;
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> argument = factory->NewTaggedArray(length);
|
||||
array_size_t index = 0;
|
||||
uint32_t index = 0;
|
||||
for (; index < firstLength; ++index) {
|
||||
argument->Set(thread, index, first->Get(index));
|
||||
}
|
||||
@ -99,15 +94,15 @@ JSHandle<TaggedArray> TaggedArray::Append(const JSThread *thread, const JSHandle
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> TaggedArray::AppendSkipHole(const JSThread *thread, const JSHandle<TaggedArray> &first,
|
||||
const JSHandle<TaggedArray> &second, array_size_t copyLength)
|
||||
const JSHandle<TaggedArray> &second, uint32_t copyLength)
|
||||
{
|
||||
array_size_t firstLength = first->GetLength();
|
||||
array_size_t secondLength = second->GetLength();
|
||||
uint32_t firstLength = first->GetLength();
|
||||
uint32_t secondLength = second->GetLength();
|
||||
ASSERT(firstLength + secondLength >= copyLength);
|
||||
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> argument = factory->NewTaggedArray(copyLength);
|
||||
array_size_t index = 0;
|
||||
uint32_t index = 0;
|
||||
for (; index < firstLength; ++index) {
|
||||
JSTaggedValue val = first->Get(index);
|
||||
if (val.IsHole()) {
|
||||
@ -116,7 +111,7 @@ JSHandle<TaggedArray> TaggedArray::AppendSkipHole(const JSThread *thread, const
|
||||
argument->Set(thread, index, val);
|
||||
ASSERT(copyLength >= index);
|
||||
}
|
||||
for (array_size_t i = 0; i < secondLength; ++i) {
|
||||
for (uint32_t i = 0; i < secondLength; ++i) {
|
||||
JSTaggedValue val = second->Get(i);
|
||||
if (val.IsHole()) {
|
||||
break;
|
||||
@ -129,9 +124,9 @@ JSHandle<TaggedArray> TaggedArray::AppendSkipHole(const JSThread *thread, const
|
||||
|
||||
inline bool TaggedArray::HasDuplicateEntry() const
|
||||
{
|
||||
array_size_t length = GetLength();
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (array_size_t j = i + 1; j < length; j++) {
|
||||
uint32_t length = GetLength();
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
for (uint32_t j = i + 1; j < length; j++) {
|
||||
if (JSTaggedValue::SameValue(Get(i), Get(j))) {
|
||||
return true;
|
||||
}
|
||||
@ -140,21 +135,21 @@ inline bool TaggedArray::HasDuplicateEntry() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void TaggedArray::InitializeWithSpecialValue(JSTaggedValue initValue, array_size_t length)
|
||||
void TaggedArray::InitializeWithSpecialValue(JSTaggedValue initValue, uint32_t length)
|
||||
{
|
||||
ASSERT(initValue.IsSpecial());
|
||||
SetLength(length);
|
||||
for (array_size_t i = 0; i < length; i++) {
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
size_t offset = JSTaggedValue::TaggedTypeSize() * i;
|
||||
Barriers::SetDynPrimitive<JSTaggedType>(GetData(), offset, initValue.GetRawData());
|
||||
}
|
||||
}
|
||||
|
||||
inline JSHandle<TaggedArray> TaggedArray::SetCapacity(const JSThread *thread, const JSHandle<TaggedArray> &array,
|
||||
array_size_t capa)
|
||||
uint32_t capa)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
array_size_t oldLength = array->GetLength();
|
||||
uint32_t oldLength = array->GetLength();
|
||||
JSHandle<TaggedArray> newArray = factory->CopyArray(array, oldLength, capa);
|
||||
return newArray;
|
||||
}
|
||||
@ -164,10 +159,10 @@ inline bool TaggedArray::IsDictionaryMode() const
|
||||
return GetClass()->IsDictionary();
|
||||
}
|
||||
|
||||
void TaggedArray::Trim(JSThread *thread, array_size_t newLength)
|
||||
void TaggedArray::Trim(JSThread *thread, uint32_t newLength)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
array_size_t oldLength = GetLength();
|
||||
uint32_t oldLength = GetLength();
|
||||
ASSERT(oldLength > newLength);
|
||||
size_t trimBytes = (oldLength - newLength) * JSTaggedValue::TaggedTypeSize();
|
||||
size_t size = TaggedArray::ComputeSize(JSTaggedValue::TaggedTypeSize(), newLength);
|
||||
|
@ -25,8 +25,8 @@ class ObjectFactory;
|
||||
|
||||
class TaggedArray : public TaggedObject {
|
||||
public:
|
||||
static constexpr array_size_t MAX_ARRAY_INDEX = std::numeric_limits<array_size_t>::max();
|
||||
static constexpr array_size_t MAX_END_UNUSED = 4;
|
||||
static constexpr uint32_t MAX_ARRAY_INDEX = std::numeric_limits<uint32_t>::max();
|
||||
static constexpr uint32_t MAX_END_UNUSED = 4;
|
||||
|
||||
inline static TaggedArray *Cast(ObjectHeader *obj)
|
||||
{
|
||||
@ -34,30 +34,28 @@ public:
|
||||
return static_cast<TaggedArray *>(obj);
|
||||
}
|
||||
|
||||
array_size_t GetLength() const;
|
||||
JSTaggedValue Get(uint32_t idx) const;
|
||||
|
||||
JSTaggedValue Get(array_size_t idx) const;
|
||||
|
||||
array_size_t GetIdx(const JSTaggedValue &value) const;
|
||||
uint32_t GetIdx(const JSTaggedValue &value) const;
|
||||
|
||||
template<typename T>
|
||||
void Set(const JSThread *thread, array_size_t idx, const JSHandle<T> &value);
|
||||
void Set(const JSThread *thread, uint32_t idx, const JSHandle<T> &value);
|
||||
|
||||
JSTaggedValue Get(const JSThread *thread, array_size_t idx) const;
|
||||
JSTaggedValue Get(const JSThread *thread, uint32_t idx) const;
|
||||
|
||||
void Set(const JSThread *thread, array_size_t idx, const JSTaggedValue &value);
|
||||
void Set(const JSThread *thread, uint32_t idx, const JSTaggedValue &value);
|
||||
|
||||
static inline JSHandle<TaggedArray> Append(const JSThread *thread, const JSHandle<TaggedArray> &first,
|
||||
const JSHandle<TaggedArray> &second);
|
||||
static inline JSHandle<TaggedArray> AppendSkipHole(const JSThread *thread, const JSHandle<TaggedArray> &first,
|
||||
const JSHandle<TaggedArray> &second, array_size_t copyLength);
|
||||
const JSHandle<TaggedArray> &second, uint32_t copyLength);
|
||||
|
||||
static inline size_t ComputeSize(size_t elemSize, array_size_t length)
|
||||
static inline size_t ComputeSize(size_t elemSize, uint32_t length)
|
||||
{
|
||||
ASSERT(elemSize != 0);
|
||||
size_t size = sizeof(TaggedArray) + elemSize * length;
|
||||
size_t size = DATA_OFFSET + elemSize * length;
|
||||
#ifdef PANDA_TARGET_32
|
||||
size_t sizeLimit = (std::numeric_limits<size_t>::max() - sizeof(TaggedArray)) / elemSize;
|
||||
size_t sizeLimit = (std::numeric_limits<size_t>::max() - DATA_OFFSET) / elemSize;
|
||||
if (UNLIKELY(sizeLimit < static_cast<size_t>(length))) {
|
||||
return 0;
|
||||
}
|
||||
@ -65,14 +63,9 @@ public:
|
||||
return size;
|
||||
}
|
||||
|
||||
JSTaggedType *GetData()
|
||||
inline JSTaggedType *GetData() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
const JSTaggedType *GetData() const
|
||||
{
|
||||
return data_;
|
||||
return reinterpret_cast<JSTaggedType *>(ToUintPtr(this) + DATA_OFFSET);
|
||||
}
|
||||
|
||||
inline bool IsDictionaryMode() const;
|
||||
@ -80,45 +73,27 @@ public:
|
||||
bool HasDuplicateEntry() const;
|
||||
|
||||
static JSHandle<TaggedArray> SetCapacity(const JSThread *thread, const JSHandle<TaggedArray> &array,
|
||||
array_size_t capa);
|
||||
uint32_t capa);
|
||||
|
||||
static constexpr uint32_t GetLengthOffset()
|
||||
{
|
||||
return MEMBER_OFFSET(TaggedArray, length_);
|
||||
}
|
||||
inline void InitializeWithSpecialValue(JSTaggedValue initValue, uint32_t length);
|
||||
|
||||
static constexpr uint32_t GetDataOffset()
|
||||
{
|
||||
return MEMBER_OFFSET(TaggedArray, data_);
|
||||
}
|
||||
|
||||
inline void InitializeWithSpecialValue(JSTaggedValue initValue, array_size_t length);
|
||||
|
||||
static inline bool ShouldTrim(JSThread *thread, array_size_t oldLength, array_size_t newLength)
|
||||
static inline bool ShouldTrim(JSThread *thread, uint32_t oldLength, uint32_t newLength)
|
||||
{
|
||||
return (oldLength - newLength > MAX_END_UNUSED);
|
||||
}
|
||||
inline void Trim(JSThread *thread, array_size_t newLength);
|
||||
void VisitRangeSlot(const EcmaObjectRangeVisitor &v)
|
||||
{
|
||||
uintptr_t dataAddr = ToUintPtr(this) + TaggedArray::GetDataOffset();
|
||||
v(this, ObjectSlot(dataAddr), ObjectSlot(dataAddr + GetLength() * JSTaggedValue::TaggedTypeSize()));
|
||||
}
|
||||
inline void Trim(JSThread *thread, uint32_t newLength);
|
||||
|
||||
static constexpr size_t LENGTH_OFFSET = TaggedObjectSize();
|
||||
SET_GET_PRIMITIVE_FIELD(Length, uint32_t, LENGTH_OFFSET, DATA_OFFSET);
|
||||
static constexpr size_t SIZE = DATA_OFFSET; // Empty Array size
|
||||
|
||||
DECL_VISIT_ARRAY(DATA_OFFSET, GetLength());
|
||||
|
||||
private:
|
||||
friend class ObjectFactory;
|
||||
|
||||
void SetLength(array_size_t length)
|
||||
{
|
||||
length_ = length;
|
||||
}
|
||||
|
||||
array_size_t length_;
|
||||
uint32_t placeholder_; // Add for 8bits align of data_
|
||||
// should align by 8, 32bit using TaggedType also
|
||||
__extension__ alignas(sizeof(JSTaggedType)) JSTaggedType data_[0]; // NOLINT(modernize-avoid-c-arrays)
|
||||
};
|
||||
|
||||
static_assert(TaggedArray::GetLengthOffset() == sizeof(TaggedObject));
|
||||
static_assert(TaggedArray::LENGTH_OFFSET == sizeof(TaggedObject));
|
||||
static_assert((TaggedArray::DATA_OFFSET % static_cast<uint8_t>(MemAlignment::MEM_ALIGN_OBJECT)) == 0);
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_TAGGED_ARRAY_H
|
||||
|
@ -59,9 +59,9 @@ void NameDictionary::GetAllKeys(const JSThread *thread, int offset, TaggedArray
|
||||
}
|
||||
}
|
||||
|
||||
void NameDictionary::GetAllEnumKeys(const JSThread *thread, int offset, TaggedArray *keyArray, array_size_t *keys) const
|
||||
void NameDictionary::GetAllEnumKeys(const JSThread *thread, int offset, TaggedArray *keyArray, uint32_t *keys) const
|
||||
{
|
||||
array_size_t arrayIndex = 0;
|
||||
uint32_t arrayIndex = 0;
|
||||
int size = Size();
|
||||
CVector<std::pair<JSTaggedValue, PropertyAttributes>> sortArr;
|
||||
for (int hashIndex = 0; hashIndex < size; hashIndex++) {
|
||||
@ -177,11 +177,11 @@ void NumberDictionary::GetAllKeys(const JSThread *thread, const JSHandle<NumberD
|
||||
}
|
||||
|
||||
void NumberDictionary::GetAllEnumKeys(const JSThread *thread, const JSHandle<NumberDictionary> &obj, int offset,
|
||||
const JSHandle<TaggedArray> &keyArray, array_size_t *keys)
|
||||
const JSHandle<TaggedArray> &keyArray, uint32_t *keys)
|
||||
{
|
||||
ASSERT_PRINT(offset + obj->EntriesCount() <= static_cast<int>(keyArray->GetLength()),
|
||||
"keyArray capacity is not enough for dictionary");
|
||||
array_size_t arrayIndex = 0;
|
||||
uint32_t arrayIndex = 0;
|
||||
int size = obj->Size();
|
||||
CVector<JSTaggedValue> sortArr;
|
||||
for (int hashIndex = 0; hashIndex < size; hashIndex++) {
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
void UpdateAttributes(int entry, const PropertyAttributes &metaData);
|
||||
void ClearEntry(const JSThread *thread, int entry);
|
||||
void GetAllKeys(const JSThread *thread, int offset, TaggedArray *keyArray) const;
|
||||
void GetAllEnumKeys(const JSThread *thread, int offset, TaggedArray *keyArray, array_size_t *keys) const;
|
||||
void GetAllEnumKeys(const JSThread *thread, int offset, TaggedArray *keyArray, uint32_t *keys) const;
|
||||
static inline bool CompKey(const std::pair<JSTaggedValue, PropertyAttributes> &a,
|
||||
const std::pair<JSTaggedValue, PropertyAttributes> &b)
|
||||
{
|
||||
@ -104,7 +104,7 @@ public:
|
||||
static void GetAllKeys(const JSThread *thread, const JSHandle<NumberDictionary> &obj, int offset,
|
||||
const JSHandle<TaggedArray> &keyArray);
|
||||
static void GetAllEnumKeys(const JSThread *thread, const JSHandle<NumberDictionary> &obj, int offset,
|
||||
const JSHandle<TaggedArray> &keyArray, array_size_t *keys);
|
||||
const JSHandle<TaggedArray> &keyArray, uint32_t *keys);
|
||||
static inline bool CompKey(const JSTaggedValue &a, const JSTaggedValue &b)
|
||||
{
|
||||
ASSERT(a.IsNumber() && b.IsNumber());
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include "ecmascript/tagged_queue.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
inline TaggedQueue *TaggedQueue::Create(JSThread *thread, array_size_t capacity, JSTaggedValue initVal)
|
||||
inline TaggedQueue *TaggedQueue::Create(JSThread *thread, uint32_t capacity, JSTaggedValue initVal)
|
||||
{
|
||||
array_size_t length = QueueToArrayIndex(capacity);
|
||||
uint32_t length = QueueToArrayIndex(capacity);
|
||||
|
||||
auto queue = TaggedQueue::Cast(*thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length, initVal));
|
||||
queue->SetStart(thread, JSTaggedValue(0)); // equal to 0 when add 1.
|
||||
@ -36,10 +36,10 @@ inline JSTaggedValue TaggedQueue::Pop(JSThread *thread)
|
||||
return JSTaggedValue::Hole();
|
||||
}
|
||||
|
||||
array_size_t start = GetStart().GetArrayLength();
|
||||
uint32_t start = GetStart().GetArrayLength();
|
||||
JSTaggedValue value = Get(start);
|
||||
|
||||
array_size_t capacity = GetCapacity().GetArrayLength();
|
||||
uint32_t capacity = GetCapacity().GetArrayLength();
|
||||
ASSERT(capacity != 0);
|
||||
SetStart(thread, JSTaggedValue((start + 1) % capacity));
|
||||
return value;
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
static TaggedQueue *Push(const JSThread *thread, const JSHandle<TaggedQueue> &queue,
|
||||
const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
array_size_t capacity = queue->GetCapacity().GetArrayLength();
|
||||
uint32_t capacity = queue->GetCapacity().GetArrayLength();
|
||||
if (capacity == 0) {
|
||||
// If there is no capacity, directly create a queue whose capacity is MIN_CAPACITY. Add elements.
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
@ -45,9 +45,9 @@ public:
|
||||
return *newQueue;
|
||||
}
|
||||
|
||||
array_size_t start = queue->GetStart().GetArrayLength();
|
||||
array_size_t end = queue->GetEnd().GetArrayLength();
|
||||
array_size_t size = queue->Size();
|
||||
uint32_t start = queue->GetStart().GetArrayLength();
|
||||
uint32_t end = queue->GetEnd().GetArrayLength();
|
||||
uint32_t size = queue->Size();
|
||||
if ((end + 1) % capacity == start) {
|
||||
// The original queue is full and needs to be expanded.
|
||||
if (capacity == MAX_QUEUE_INDEX) {
|
||||
@ -56,11 +56,11 @@ public:
|
||||
}
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
// Grow Array for 1.5 times
|
||||
array_size_t newCapacity = capacity + (capacity >> 1U);
|
||||
uint32_t newCapacity = capacity + (capacity >> 1U);
|
||||
newCapacity = newCapacity < capacity ? MAX_QUEUE_INDEX : newCapacity;
|
||||
JSHandle<TaggedQueue> newQueue = factory->NewTaggedQueue(newCapacity);
|
||||
array_size_t newEnd = 0;
|
||||
for (array_size_t i = start; newEnd < size; i = (i + 1) % capacity) {
|
||||
uint32_t newEnd = 0;
|
||||
for (uint32_t i = start; newEnd < size; i = (i + 1) % capacity) {
|
||||
newQueue->Set(thread, newEnd, queue->Get(i));
|
||||
newEnd++;
|
||||
}
|
||||
@ -80,8 +80,8 @@ public:
|
||||
static inline void PushFixedQueue(const JSThread *thread, const JSHandle<TaggedQueue> &queue,
|
||||
const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
array_size_t end = queue->GetEnd().GetArrayLength();
|
||||
array_size_t capacity = queue->GetCapacity().GetArrayLength();
|
||||
uint32_t end = queue->GetEnd().GetArrayLength();
|
||||
uint32_t capacity = queue->GetCapacity().GetArrayLength();
|
||||
ASSERT(capacity != 0);
|
||||
queue->Set(thread, end, value.GetTaggedValue());
|
||||
queue->SetEnd(thread, JSTaggedValue((end + 1) % capacity));
|
||||
@ -97,7 +97,7 @@ public:
|
||||
if (Empty()) {
|
||||
return JSTaggedValue::Hole();
|
||||
}
|
||||
array_size_t start = GetStart().GetArrayLength();
|
||||
uint32_t start = GetStart().GetArrayLength();
|
||||
return JSTaggedValue(Get(start));
|
||||
}
|
||||
|
||||
@ -109,38 +109,38 @@ public:
|
||||
return JSTaggedValue(Get(GetEnd().GetArrayLength() - 1));
|
||||
}
|
||||
|
||||
inline array_size_t Size()
|
||||
inline uint32_t Size()
|
||||
{
|
||||
array_size_t capacity = GetCapacity().GetArrayLength();
|
||||
uint32_t capacity = GetCapacity().GetArrayLength();
|
||||
if (capacity == 0) {
|
||||
return 0;
|
||||
}
|
||||
array_size_t end = GetEnd().GetArrayLength();
|
||||
array_size_t start = GetStart().GetArrayLength();
|
||||
uint32_t end = GetEnd().GetArrayLength();
|
||||
uint32_t start = GetStart().GetArrayLength();
|
||||
return (end - start + capacity) % capacity;
|
||||
}
|
||||
|
||||
inline JSTaggedValue Get(array_size_t index) const
|
||||
inline JSTaggedValue Get(uint32_t index) const
|
||||
{
|
||||
return TaggedArray::Get(QueueToArrayIndex(index));
|
||||
}
|
||||
|
||||
inline void Set(const JSThread *thread, array_size_t index, JSTaggedValue value)
|
||||
inline void Set(const JSThread *thread, uint32_t index, JSTaggedValue value)
|
||||
{
|
||||
return TaggedArray::Set(thread, QueueToArrayIndex(index), value);
|
||||
}
|
||||
|
||||
static const array_size_t MIN_CAPACITY = 2;
|
||||
static const array_size_t CAPACITY_INDEX = 0;
|
||||
static const array_size_t START_INDEX = 1;
|
||||
static const array_size_t END_INDEX = 2;
|
||||
static const array_size_t ELEMENTS_START_INDEX = 3;
|
||||
static const array_size_t MAX_QUEUE_INDEX = TaggedArray::MAX_ARRAY_INDEX - ELEMENTS_START_INDEX;
|
||||
static const uint32_t MIN_CAPACITY = 2;
|
||||
static const uint32_t CAPACITY_INDEX = 0;
|
||||
static const uint32_t START_INDEX = 1;
|
||||
static const uint32_t END_INDEX = 2;
|
||||
static const uint32_t ELEMENTS_START_INDEX = 3;
|
||||
static const uint32_t MAX_QUEUE_INDEX = TaggedArray::MAX_ARRAY_INDEX - ELEMENTS_START_INDEX;
|
||||
|
||||
private:
|
||||
friend class ObjectFactory;
|
||||
|
||||
inline static constexpr array_size_t QueueToArrayIndex(array_size_t index)
|
||||
inline static constexpr uint32_t QueueToArrayIndex(uint32_t index)
|
||||
{
|
||||
return index + ELEMENTS_START_INDEX;
|
||||
}
|
||||
@ -175,7 +175,7 @@ private:
|
||||
return TaggedArray::Get(END_INDEX);
|
||||
}
|
||||
|
||||
static TaggedQueue *Create(JSThread *thread, array_size_t capacity, JSTaggedValue initVal = JSTaggedValue::Hole());
|
||||
static TaggedQueue *Create(JSThread *thread, uint32_t capacity, JSTaggedValue initVal = JSTaggedValue::Hole());
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_TAGGED_QUEUE_H
|
@ -61,7 +61,7 @@ public:
|
||||
TestHelper::DestroyEcmaVMWithScope(instance, scope);
|
||||
}
|
||||
|
||||
JSHandle<TaggedArray> CreateTaggedArray(array_size_t length, JSTaggedValue initVal, MemSpaceType spaceType)
|
||||
JSHandle<TaggedArray> CreateTaggedArray(uint32_t length, JSTaggedValue initVal, MemSpaceType spaceType)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
return factory->NewTaggedArray(length, initVal, spaceType);
|
||||
@ -74,18 +74,18 @@ public:
|
||||
|
||||
HWTEST_F_L0(ConcurrentMarkingTest, PerformanceWithConcurrentMarking)
|
||||
{
|
||||
array_size_t rootLength = 1024;
|
||||
uint32_t rootLength = 1024;
|
||||
JSHandle<TaggedArray> rootArray =
|
||||
CreateTaggedArray(rootLength, JSTaggedValue::Undefined(), MemSpaceType::OLD_SPACE);
|
||||
for (array_size_t i = 0; i < rootLength; i++) {
|
||||
array_size_t subArrayLength = 1024;
|
||||
for (uint32_t i = 0; i < rootLength; i++) {
|
||||
uint32_t subArrayLength = 1024;
|
||||
auto array = CreateTaggedArray(subArrayLength, JSTaggedValue::Undefined(), MemSpaceType::OLD_SPACE);
|
||||
rootArray->Set(thread, i, array);
|
||||
}
|
||||
auto heap = const_cast<Heap *>(thread->GetEcmaVM()->GetHeap());
|
||||
heap->TriggerConcurrentMarking(); // concurrent mark
|
||||
for (array_size_t i = 0; i < rootLength; i++) {
|
||||
array_size_t subArrayLength = 1024;
|
||||
for (uint32_t i = 0; i < rootLength; i++) {
|
||||
uint32_t subArrayLength = 1024;
|
||||
auto array = CreateTaggedArray(subArrayLength, JSTaggedValue::Undefined(), MemSpaceType::OLD_SPACE);
|
||||
rootArray->Set(thread, i, array);
|
||||
}
|
||||
@ -94,17 +94,17 @@ HWTEST_F_L0(ConcurrentMarkingTest, PerformanceWithConcurrentMarking)
|
||||
|
||||
HWTEST_F_L0(ConcurrentMarkingTest, PerformanceWithoutConcurrentMarking)
|
||||
{
|
||||
array_size_t rootLength = 1024;
|
||||
uint32_t rootLength = 1024;
|
||||
JSHandle<TaggedArray> rootArray =
|
||||
CreateTaggedArray(rootLength, JSTaggedValue::Undefined(), MemSpaceType::OLD_SPACE);
|
||||
for (array_size_t i = 0; i < rootLength; i++) {
|
||||
array_size_t subArrayLength = 1024;
|
||||
for (uint32_t i = 0; i < rootLength; i++) {
|
||||
uint32_t subArrayLength = 1024;
|
||||
auto array = CreateTaggedArray(subArrayLength, JSTaggedValue::Undefined(), MemSpaceType::OLD_SPACE);
|
||||
rootArray->Set(thread, i, array);
|
||||
}
|
||||
auto heap = const_cast<Heap *>(thread->GetEcmaVM()->GetHeap());
|
||||
for (array_size_t i = 0; i < rootLength; i++) {
|
||||
array_size_t subArrayLength = 1024;
|
||||
for (uint32_t i = 0; i < rootLength; i++) {
|
||||
uint32_t subArrayLength = 1024;
|
||||
auto array = CreateTaggedArray(subArrayLength, JSTaggedValue::Undefined(), MemSpaceType::OLD_SPACE);
|
||||
rootArray->Set(thread, i, array);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ HWTEST_F_L0(EcmaStringTest, ComputeSizeUtf8)
|
||||
uint32_t scale = 3333;
|
||||
for (uint32_t i = 0x40000000U - 1; i > scale; i = i - scale) {
|
||||
uint32_t length = i;
|
||||
EXPECT_EQ(EcmaString::ComputeSizeUtf8(length), length + sizeof(EcmaString));
|
||||
EXPECT_EQ(EcmaString::ComputeSizeUtf8(length), length + EcmaString::SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ HWTEST_F_L0(EcmaStringTest, ComputeSizeUtf16)
|
||||
uint32_t scale = 3333;
|
||||
for (uint32_t i = 0x40000000U - 1; i > scale; i = i - scale) {
|
||||
uint32_t length = i;
|
||||
EXPECT_EQ(EcmaString::ComputeSizeUtf16(length), 2 * length + sizeof(EcmaString));
|
||||
EXPECT_EQ(EcmaString::ComputeSizeUtf16(length), 2 * length + EcmaString::SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,38 +258,38 @@ HWTEST_F_L0(EcmaStringTest, ObjectSize)
|
||||
EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance);
|
||||
|
||||
JSHandle<EcmaString> handleEcmaStrEmpty(thread, EcmaString::CreateEmptyString(ecmaVMPtr));
|
||||
EXPECT_EQ(handleEcmaStrEmpty->ObjectSize(), sizeof(EcmaString) + 0);
|
||||
EXPECT_EQ(handleEcmaStrEmpty->ObjectSize(), EcmaString::SIZE + 0);
|
||||
|
||||
size_t lengthEcmaStrAllocComp = 5;
|
||||
JSHandle<EcmaString> handleEcmaStrAllocComp(thread,
|
||||
EcmaString::AllocStringObject(lengthEcmaStrAllocComp, true, ecmaVMPtr));
|
||||
EXPECT_EQ(handleEcmaStrAllocComp->ObjectSize(), sizeof(EcmaString) + sizeof(uint8_t) * lengthEcmaStrAllocComp);
|
||||
EXPECT_EQ(handleEcmaStrAllocComp->ObjectSize(), EcmaString::SIZE + sizeof(uint8_t) * lengthEcmaStrAllocComp);
|
||||
|
||||
size_t lengthEcmaStrAllocNotComp = 5;
|
||||
JSHandle<EcmaString> handleEcmaStrAllocNotComp(thread,
|
||||
EcmaString::AllocStringObject(lengthEcmaStrAllocNotComp, false, ecmaVMPtr));
|
||||
EXPECT_EQ(handleEcmaStrAllocNotComp->ObjectSize(),
|
||||
sizeof(EcmaString) + sizeof(uint16_t) * lengthEcmaStrAllocNotComp);
|
||||
EcmaString::SIZE + sizeof(uint16_t) * lengthEcmaStrAllocNotComp);
|
||||
|
||||
uint8_t arrayU8[] = {"abcde"};
|
||||
size_t lengthEcmaStrU8 = sizeof(arrayU8) - 1;
|
||||
JSHandle<EcmaString> handleEcmaStrU8(thread,
|
||||
EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true));
|
||||
EXPECT_EQ(handleEcmaStrU8->ObjectSize(), sizeof(EcmaString) + sizeof(uint8_t) * lengthEcmaStrU8);
|
||||
EXPECT_EQ(handleEcmaStrU8->ObjectSize(), EcmaString::SIZE + sizeof(uint8_t) * lengthEcmaStrU8);
|
||||
|
||||
// ObjectSize(). EcmaString made by CreateFromUtf16( , , , true).
|
||||
uint16_t arrayU16Comp[] = {1, 23, 45, 67, 127};
|
||||
size_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]);
|
||||
JSHandle<EcmaString> handleEcmaStrU16Comp(thread,
|
||||
EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true));
|
||||
EXPECT_EQ(handleEcmaStrU16Comp->ObjectSize(), sizeof(EcmaString) + sizeof(uint8_t) * lengthEcmaStrU16Comp);
|
||||
EXPECT_EQ(handleEcmaStrU16Comp->ObjectSize(), EcmaString::SIZE + sizeof(uint8_t) * lengthEcmaStrU16Comp);
|
||||
|
||||
// ObjectSize(). EcmaString made by CreateFromUtf16( , , , false).
|
||||
uint16_t arrayU16NotComp[] = {127, 128, 256, 11100, 65535};
|
||||
size_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]);
|
||||
JSHandle<EcmaString> handleEcmaStrU16NotComp(thread,
|
||||
EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false));
|
||||
EXPECT_EQ(handleEcmaStrU16NotComp->ObjectSize(), sizeof(EcmaString) + sizeof(uint16_t) * lengthEcmaStrU16NotComp);
|
||||
EXPECT_EQ(handleEcmaStrU16NotComp->ObjectSize(), EcmaString::SIZE + sizeof(uint16_t) * lengthEcmaStrU16NotComp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1180,7 +1180,7 @@ HWTEST_F_L0(JSObjectTest, NoticeThroughChain)
|
||||
JSTaggedValue listeners1Value = ProtoChangeDetails::Cast(protoDetails1.GetTaggedObject())->GetChangeListener();
|
||||
EXPECT_TRUE(listeners1Value != JSTaggedValue(0));
|
||||
JSHandle<ChangeListener> listeners1(thread, listeners1Value.GetTaggedObject());
|
||||
array_size_t holeIndex = ChangeListener::CheckHole(listeners1);
|
||||
uint32_t holeIndex = ChangeListener::CheckHole(listeners1);
|
||||
EXPECT_TRUE(holeIndex == 0);
|
||||
|
||||
JSTaggedValue protoDetails2 = obj2Dynclass->GetProtoChangeDetails();
|
||||
|
@ -45,7 +45,7 @@ using ecmascript::JSRuntimeOptions;
|
||||
class TestHelper {
|
||||
public:
|
||||
static std::unique_ptr<EcmaRuntimeCallInfo> CreateEcmaRuntimeCallInfo(JSThread *thread, JSTaggedValue newTgt,
|
||||
array_size_t argvLength)
|
||||
uint32_t argvLength)
|
||||
{
|
||||
const uint8_t testDecodedSize = 2;
|
||||
// argvLength includes number of int64_t to store value and tag of function, 'this' and call args
|
||||
|
@ -702,9 +702,9 @@ void JSBackend::GetProperties(uint32_t objectId, bool isOwn, bool isAccessorOnly
|
||||
return;
|
||||
}
|
||||
Local<ArrayRef> keys = Local<ObjectRef>(value)->GetOwnPropertyNames(ecmaVm_);
|
||||
array_size_t length = keys->Length(ecmaVm_);
|
||||
uint32_t length = keys->Length(ecmaVm_);
|
||||
Local<JSValueRef> name = JSValueRef::Undefined(ecmaVm_);
|
||||
for (array_size_t i = 0; i < length; ++i) {
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
name = keys->Get(ecmaVm_, i);
|
||||
PropertyAttribute jsProperty = PropertyAttribute::Default();
|
||||
if (!Local<ObjectRef>(value)->GetOwnProperty(ecmaVm_, name, jsProperty)) {
|
||||
|
@ -309,7 +309,7 @@ std::unique_ptr<SetBlackboxPatternsParams> SetBlackboxPatternsParams::Create(con
|
||||
Local<ArrayRef> array = Local<ArrayRef>(result);
|
||||
uint32_t len = array->Length(ecmaVm);
|
||||
Local<JSValueRef> key = JSValueRef::Undefined(ecmaVm);
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
key = IntegerRef::New(ecmaVm, i);
|
||||
Local<JSValueRef> value = Local<ObjectRef>(array)->Get(ecmaVm, key->ToString(ecmaVm));
|
||||
if (value->IsString()) {
|
||||
@ -460,7 +460,7 @@ std::unique_ptr<StepIntoParams> StepIntoParams::Create(const EcmaVM *ecmaVm, con
|
||||
Local<ArrayRef> array = Local<ArrayRef>(result);
|
||||
uint32_t len = array->Length(ecmaVm);
|
||||
Local<JSValueRef> key = JSValueRef::Undefined(ecmaVm);
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
key = IntegerRef::New(ecmaVm, i);
|
||||
Local<JSValueRef> value = Local<ObjectRef>(array)->Get(ecmaVm, key->ToString(ecmaVm));
|
||||
if (value->IsObject()) {
|
||||
@ -503,7 +503,7 @@ std::unique_ptr<StepOverParams> StepOverParams::Create(const EcmaVM *ecmaVm, con
|
||||
Local<ArrayRef> array = Local<ArrayRef>(result);
|
||||
uint32_t len = array->Length(ecmaVm);
|
||||
Local<JSValueRef> key = JSValueRef::Undefined(ecmaVm);
|
||||
for (array_size_t i = 0; i < len; i++) {
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
key = IntegerRef::New(ecmaVm, i);
|
||||
Local<JSValueRef> value = Local<ObjectRef>(array)->Get(ecmaVm, key->ToString(ecmaVm));
|
||||
if (value->IsObject()) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "tagged_array-inl.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
array_size_t WeakVector::GetEnd() const
|
||||
uint32_t WeakVector::GetEnd() const
|
||||
{
|
||||
return TaggedArray::Get(END_INDEX).GetArrayLength();
|
||||
}
|
||||
@ -35,24 +35,24 @@ bool WeakVector::Empty() const
|
||||
return GetEnd() == 0;
|
||||
}
|
||||
|
||||
array_size_t WeakVector::GetCapacity() const
|
||||
uint32_t WeakVector::GetCapacity() const
|
||||
{
|
||||
return TaggedArray::GetLength() - ELEMENTS_START_INDEX;
|
||||
}
|
||||
|
||||
JSTaggedValue WeakVector::Get(array_size_t index) const
|
||||
JSTaggedValue WeakVector::Get(uint32_t index) const
|
||||
{
|
||||
ASSERT(index < GetCapacity());
|
||||
return TaggedArray::Get(VectorToArrayIndex(index));
|
||||
}
|
||||
|
||||
void WeakVector::Set(const JSThread *thread, array_size_t index, JSTaggedValue value)
|
||||
void WeakVector::Set(const JSThread *thread, uint32_t index, JSTaggedValue value)
|
||||
{
|
||||
ASSERT(index < GetCapacity());
|
||||
TaggedArray::Set(thread, VectorToArrayIndex(index), value);
|
||||
}
|
||||
|
||||
void WeakVector::SetEnd(const JSThread *thread, array_size_t end)
|
||||
void WeakVector::SetEnd(const JSThread *thread, uint32_t end)
|
||||
{
|
||||
ASSERT(end <= GetCapacity());
|
||||
TaggedArray::Set(thread, END_INDEX, JSTaggedValue(end));
|
||||
|
@ -18,20 +18,20 @@
|
||||
#include "ecmascript/weak_vector-inl.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
JSHandle<WeakVector> WeakVector::Create(const JSThread *thread, array_size_t capacity)
|
||||
JSHandle<WeakVector> WeakVector::Create(const JSThread *thread, uint32_t capacity)
|
||||
{
|
||||
ASSERT(capacity < MAX_VECTOR_INDEX);
|
||||
|
||||
array_size_t length = VectorToArrayIndex(capacity);
|
||||
uint32_t length = VectorToArrayIndex(capacity);
|
||||
JSHandle<WeakVector> vector = JSHandle<WeakVector>(thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length));
|
||||
|
||||
vector->SetEnd(thread, 0);
|
||||
return vector;
|
||||
}
|
||||
|
||||
bool WeakVector::Delete(const JSThread *thread, array_size_t index)
|
||||
bool WeakVector::Delete(const JSThread *thread, uint32_t index)
|
||||
{
|
||||
array_size_t end = GetEnd();
|
||||
uint32_t end = GetEnd();
|
||||
if (index < end) {
|
||||
Set(thread, index, JSTaggedValue::Hole());
|
||||
return true;
|
||||
@ -39,9 +39,9 @@ bool WeakVector::Delete(const JSThread *thread, array_size_t index)
|
||||
return false;
|
||||
}
|
||||
|
||||
JSHandle<WeakVector> WeakVector::Grow(const JSThread *thread, const JSHandle<WeakVector> &old, array_size_t newCapacity)
|
||||
JSHandle<WeakVector> WeakVector::Grow(const JSThread *thread, const JSHandle<WeakVector> &old, uint32_t newCapacity)
|
||||
{
|
||||
array_size_t oldCapacity = old->GetCapacity();
|
||||
uint32_t oldCapacity = old->GetCapacity();
|
||||
ASSERT(newCapacity > oldCapacity);
|
||||
if (oldCapacity == MAX_VECTOR_INDEX) {
|
||||
return old;
|
||||
@ -58,9 +58,9 @@ JSHandle<WeakVector> WeakVector::Grow(const JSThread *thread, const JSHandle<Wea
|
||||
return JSHandle<WeakVector>(newVec);
|
||||
}
|
||||
|
||||
array_size_t WeakVector::PushBack(const JSThread *thread, JSTaggedValue value)
|
||||
uint32_t WeakVector::PushBack(const JSThread *thread, JSTaggedValue value)
|
||||
{
|
||||
array_size_t end = GetEnd();
|
||||
uint32_t end = GetEnd();
|
||||
if (end == GetCapacity()) {
|
||||
return TaggedArray::MAX_ARRAY_INDEX;
|
||||
}
|
||||
|
@ -28,37 +28,37 @@ public:
|
||||
return static_cast<WeakVector *>(object);
|
||||
}
|
||||
|
||||
static constexpr array_size_t DEFALUT_CAPACITY = 4;
|
||||
static JSHandle<WeakVector> Create(const JSThread *thread, array_size_t capacity = DEFALUT_CAPACITY);
|
||||
static JSHandle<WeakVector> Grow(const JSThread *thread, const JSHandle<WeakVector> &old, array_size_t newCapacity);
|
||||
array_size_t PushBack(const JSThread *thread, JSTaggedValue value);
|
||||
static constexpr uint32_t DEFALUT_CAPACITY = 4;
|
||||
static JSHandle<WeakVector> Create(const JSThread *thread, uint32_t capacity = DEFALUT_CAPACITY);
|
||||
static JSHandle<WeakVector> Grow(const JSThread *thread, const JSHandle<WeakVector> &old, uint32_t newCapacity);
|
||||
uint32_t PushBack(const JSThread *thread, JSTaggedValue value);
|
||||
// just set index value to Hole
|
||||
bool Delete(const JSThread *thread, array_size_t index);
|
||||
bool Delete(const JSThread *thread, uint32_t index);
|
||||
|
||||
inline array_size_t GetEnd() const;
|
||||
inline uint32_t GetEnd() const;
|
||||
|
||||
inline bool Full() const;
|
||||
|
||||
inline bool Empty() const;
|
||||
|
||||
inline array_size_t GetCapacity() const;
|
||||
inline uint32_t GetCapacity() const;
|
||||
|
||||
inline JSTaggedValue Get(array_size_t index) const;
|
||||
inline JSTaggedValue Get(uint32_t index) const;
|
||||
|
||||
inline void Set(const JSThread *thread, array_size_t index, JSTaggedValue value);
|
||||
inline void Set(const JSThread *thread, uint32_t index, JSTaggedValue value);
|
||||
|
||||
private:
|
||||
static const array_size_t MIN_CAPACITY = 2;
|
||||
static const array_size_t END_INDEX = 0;
|
||||
static const array_size_t ELEMENTS_START_INDEX = 1;
|
||||
static const array_size_t MAX_VECTOR_INDEX = TaggedArray::MAX_ARRAY_INDEX - ELEMENTS_START_INDEX;
|
||||
static const uint32_t MIN_CAPACITY = 2;
|
||||
static const uint32_t END_INDEX = 0;
|
||||
static const uint32_t ELEMENTS_START_INDEX = 1;
|
||||
static const uint32_t MAX_VECTOR_INDEX = TaggedArray::MAX_ARRAY_INDEX - ELEMENTS_START_INDEX;
|
||||
|
||||
inline static constexpr array_size_t VectorToArrayIndex(array_size_t index)
|
||||
inline static constexpr uint32_t VectorToArrayIndex(uint32_t index)
|
||||
{
|
||||
return index + ELEMENTS_START_INDEX;
|
||||
}
|
||||
|
||||
inline void SetEnd(const JSThread *thread, array_size_t end);
|
||||
inline void SetEnd(const JSThread *thread, uint32_t end);
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_WEAK_VECTOR_H
|
||||
|
Loading…
Reference in New Issue
Block a user