Fixed data type under builtins (int->uint)

Signed-off-by: hwx1163501 <hanjing35@huawei.com>
https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7LLDJ
This commit is contained in:
hwx1163501 2023-07-20 09:23:42 +08:00
parent 56ba68b8eb
commit 7b47de5a55
24 changed files with 72 additions and 71 deletions

View File

@ -221,7 +221,7 @@ JSTaggedValue BuiltinsArray::From(EcmaRuntimeCallInfo *argv)
// 3. Let mappedValue be mappedValue.[[value]].
// viii. Else, let mappedValue be nextValue.
if (mapping) {
const int32_t argsLength = 2; // 2: «nextValue, k»
const uint32_t argsLength = 2; // 2: «nextValue, k»
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, mapfn, thisArgHandle, undefined, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
@ -982,7 +982,7 @@ JSTaggedValue BuiltinsArray::Find(EcmaRuntimeCallInfo *argv)
JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
key.Update(JSTaggedValue(k));
const int32_t argsLength = 3; // 3: «kValue, k, O»
const uint32_t argsLength = 3; // 3: «kValue, k, O»
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
@ -1115,7 +1115,7 @@ JSTaggedValue BuiltinsArray::ForEach(EcmaRuntimeCallInfo *argv)
JSStableArray::HandleforEachOfStable(thread, thisObjHandle, callbackFnHandle, thisArgHandle, k);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
}
const int32_t argsLength = 3; // 3: «kValue, k, O»
const uint32_t argsLength = 3; // 3: «kValue, k, O»
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
while (k < len) {
bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, k);

View File

@ -87,7 +87,7 @@ JSTaggedValue BuiltinsArrayBuffer::GetByteLength(EcmaRuntimeCallInfo *argv)
JSThread *thread = argv->GetThread();
BUILTINS_API_TRACE(thread, ArrayBuffer, GetByteLength);
[[maybe_unused]] EcmaHandleScope handleScope(thread);
// 1. Let O be the this value.
JSHandle<JSTaggedValue> thisHandle = GetThis(argv);
// 2. If Type(O) is not Object, throw a TypeError exception.

View File

@ -125,14 +125,14 @@ JSTaggedValue BuiltinsFunction::FunctionPrototypeApply(EcmaRuntimeCallInfo *argv
JSObject::CreateListFromArrayLike(thread, arrayObj));
// 4. ReturnIfAbrupt(argList).
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
const int32_t argsLength = static_cast<int32_t>(argList->GetLength());
const uint32_t argsLength = argList->GetLength();
EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, func, thisArg, undefined, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
info->SetCallArg(argsLength, argList);
return JSFunction::Call(info);
}
// 6. Return Call(func, thisArg, argList).
const int32_t argsLength = static_cast<int32_t>(argumentsList.second);
const uint32_t argsLength = static_cast<uint32_t>(argumentsList.second);
EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, func, thisArg, undefined, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
info->SetCallArg(argsLength, argumentsList.first);

View File

@ -180,7 +180,7 @@ JSTaggedValue BuiltinsMap::ForEach(EcmaRuntimeCallInfo *argv)
JSHandle<JSTaggedValue> thisArg = GetCallArg(argv, 1);
JSMutableHandle<LinkedHashMap> hashMap(thread, map->GetLinkedMap());
const int32_t argsLength = 3;
const uint32_t argsLength = 3;
int index = 0;
int totalElements = hashMap->NumberOfElements() + hashMap->NumberOfDeletedElements();
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
@ -314,7 +314,7 @@ JSTaggedValue BuiltinsMap::AddEntriesFromIterable(JSThread *thread, const JSHand
if (thread->HasPendingException()) {
return JSIterator::IteratorCloseAndReturn(thread, iter);
}
const int32_t argsLength = 2; // 2: key and value pair
const uint32_t argsLength = 2; // 2: key and value pair
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, adder, JSHandle<JSTaggedValue>(target), undefined, argsLength);

View File

@ -73,7 +73,7 @@ JSTaggedValue BuiltinsPromise::PromiseConstructor(EcmaRuntimeCallInfo *argv)
auto resolveFunc = resolvingFunction->GetResolveFunction();
auto rejectFunc = resolvingFunction->GetRejectFunction();
JSHandle<JSTaggedValue> undefined = globalConst->GetHandledUndefined();
const int32_t argsLength = 2; // 2: «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»
const uint32_t argsLength = 2; // 2: «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»
EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, executor, undefined, undefined, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
info->SetCallArg(resolveFunc, rejectFunc);

View File

@ -52,7 +52,7 @@ JSTaggedValue BuiltinsPromiseJob::PromiseReactionJob(EcmaRuntimeCallInfo *argv)
// 3. Let handler be reaction.[[Handler]].
JSHandle<JSTaggedValue> handler(thread, reaction->GetHandler());
JSHandle<JSTaggedValue> call(thread, capability->GetResolve());
const int32_t argsLength = 1;
const uint32_t argsLength = 1;
JSHandle<JSTaggedValue> undefined = globalConst->GetHandledUndefined();
EcmaRuntimeCallInfo *runtimeInfo =
EcmaInterpreter::NewRuntimeCallInfo(thread, call, undefined, undefined, argsLength);
@ -104,7 +104,7 @@ JSTaggedValue BuiltinsPromiseJob::PromiseResolveThenableJob(EcmaRuntimeCallInfo
JSHandle<JSTaggedValue> then = GetCallArg(argv, BuiltinsBase::ArgsPosition::THIRD);
// 2. Let thenCallResult be Call(then, thenable, «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
const int32_t argsLength = 2; // 2: «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»
const uint32_t argsLength = 2; // 2: «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, then, thenable, undefined, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);

View File

@ -40,7 +40,7 @@ JSTaggedValue BuiltinsReflect::ReflectApply(EcmaRuntimeCallInfo *argv)
// 3. Perform PrepareForTailCall().
// 4. Return ? Call(target, thisArgument, args).
const int32_t argsLength = static_cast<int32_t>(args->GetLength());
const uint32_t argsLength = args->GetLength();
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, target, thisArgument, undefined, argsLength);
@ -75,7 +75,7 @@ JSTaggedValue BuiltinsReflect::ReflectConstruct(EcmaRuntimeCallInfo *argv)
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<TaggedArray> args = JSHandle<TaggedArray>::Cast(argOrAbrupt);
// 5. Return ? Construct(target, args, newTarget).
const int32_t argsLength = static_cast<int32_t>(args->GetLength());
const uint32_t argsLength = args->GetLength();
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, target, undefined, newTarget, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);

View File

@ -961,7 +961,7 @@ JSTaggedValue BuiltinsRegExp::Replace(EcmaRuntimeCallInfo *argv)
replacerArgs->Set(thread, index + 3, namedCaptures.GetTaggedValue()); // 3: position of groups
}
// iv. Let replValue be Call(replaceValue, undefined, replacerArgs).
const int32_t argsLength = static_cast<int32_t>(replacerArgs->GetLength());
const uint32_t argsLength = replacerArgs->GetLength();
JSHandle<JSTaggedValue> undefined = globalConst->GetHandledUndefined();
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, inputReplaceValue, undefined, undefined, argsLength);

View File

@ -205,7 +205,7 @@ JSTaggedValue BuiltinsSet::ForEach(EcmaRuntimeCallInfo *argv)
// 6.Let entries be the List that is the value of Ss [[SetData]] internal slot.
JSMutableHandle<LinkedHashSet> hashSet(thread, set->GetLinkedSet());
const int32_t argsLength = 3;
const uint32_t argsLength = 3;
int index = 0;
int totalElements = hashSet->NumberOfElements() + hashSet->NumberOfDeletedElements();
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();

View File

@ -859,7 +859,7 @@ JSTaggedValue BuiltinsString::Replace(EcmaRuntimeCallInfo *argv)
// If replacer is not undefined, then
if (!replaceMethod->IsUndefined()) {
// Return Call(replacer, searchValue, «O, replaceValue»).
const int32_t argsLength = 2;
const uint32_t argsLength = 2;
JSHandle<JSTaggedValue> undefined = globalConst->GetHandledUndefined();
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, replaceMethod, searchTag, undefined, argsLength);
@ -897,7 +897,7 @@ JSTaggedValue BuiltinsString::Replace(EcmaRuntimeCallInfo *argv)
// If functionalReplace is true, then
if (replaceTag->IsCallable()) {
// Let replValue be Call(replaceValue, undefined,«matched, pos, and string»).
const int32_t argsLength = 3; // 3: «matched, pos, and string»
const uint32_t argsLength = 3; // 3: «matched, pos, and string»
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, replaceTag, undefined, undefined, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
@ -1022,7 +1022,7 @@ JSTaggedValue BuiltinsString::ReplaceAll(EcmaRuntimeCallInfo *argv)
// If functionalReplace is true, then
if (replaceTag->IsCallable()) {
// Let replValue be Call(replaceValue, undefined,«matched, pos, and string»).
const int32_t argsLength = 3; // 3: «matched, pos, and string»
const uint32_t argsLength = 3; // 3: «matched, pos, and string»
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, replaceTag, undefined, undefined, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
@ -1370,7 +1370,7 @@ JSTaggedValue BuiltinsString::Split(EcmaRuntimeCallInfo *argv)
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (!splitter->IsUndefined()) {
// Return Call(splitter, separator, «O, limit»).
const int32_t argsLength = 2;
const uint32_t argsLength = 2;
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, splitter, seperatorTag, undefined, argsLength);

View File

@ -222,7 +222,7 @@ JSTaggedValue BuiltinsTypedArray::From(EcmaRuntimeCallInfo *argv)
// vi. Set k to k + 1.
JSMutableHandle<JSTaggedValue> tKey(thread, JSTaggedValue::Undefined());
JSMutableHandle<JSTaggedValue> mapValue(thread, JSTaggedValue::Undefined());
const int32_t argsLength = 2;
const uint32_t argsLength = 2;
uint32_t k = 0;
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
while (k < len) {
@ -277,7 +277,7 @@ JSTaggedValue BuiltinsTypedArray::From(EcmaRuntimeCallInfo *argv)
// e. Perform ? Set(targetObj, Pk, mappedValue, true).
// f. Set k to k + 1.
JSMutableHandle<JSTaggedValue> tKey(thread, JSTaggedValue::Undefined());
const int32_t argsLength = 2;
const uint32_t argsLength = 2;
int64_t k = 0;
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
JSMutableHandle<JSTaggedValue> kValue(thread, JSTaggedValue::Undefined());
@ -521,7 +521,7 @@ JSTaggedValue BuiltinsTypedArray::Every(EcmaRuntimeCallInfo *argv)
// v. If testResult is false, return false.
// e. Increase k by 1.
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
const int32_t argsLength = 3;
const uint32_t argsLength = 3;
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
uint32_t k = 0;
while (k < len) {
@ -708,7 +708,7 @@ JSTaggedValue BuiltinsTypedArray::ForEach(EcmaRuntimeCallInfo *argv)
// iv. ReturnIfAbrupt(funcResult).
// e. Increase k by 1.
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
const int32_t argsLength = 3;
const uint32_t argsLength = 3;
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
uint32_t k = 0;
while (k < len) {
@ -936,7 +936,7 @@ JSTaggedValue BuiltinsTypedArray::Map(EcmaRuntimeCallInfo *argv)
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
JSMutableHandle<JSTaggedValue> mapValue(thread, JSTaggedValue::Undefined());
JSMutableHandle<JSTaggedValue> kValue(thread, JSTaggedValue::Undefined());
const int32_t argsLength = 3;
const uint32_t argsLength = 3;
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
for (uint32_t k = 0; k < len; k++) {
key.Update(JSTaggedValue(k));
@ -1513,7 +1513,7 @@ JSTaggedValue BuiltinsTypedArray::Subarray(EcmaRuntimeCallInfo *argv)
// 21. Let argumentsList be «buffer, beginByteOffset, newLength».
// 5. Let buffer be the value of Os [[ViewedArrayBuffer]] internal slot.
// 22. Return Construct(constructor, argumentsList).
const int32_t argsLength = 3;
const uint32_t argsLength = 3;
JSTaggedType args[argsLength] = {
buffer.GetRawData(),
JSTaggedValue(beginByteOffset).GetRawData(),

View File

@ -548,9 +548,9 @@ JSTaggedValue ContainersLightWeightMap::ForEach(EcmaRuntimeCallInfo *argv)
JSMutableHandle<TaggedArray> keys(thread, tmap->GetKeys());
JSMutableHandle<TaggedArray> values(thread, tmap->GetValues());
int index = 0;
int32_t length = tmap->GetSize();
const int32_t argsLength = 3;
uint32_t index = 0;
uint32_t length = tmap->GetSize();
const uint32_t argsLength = 3;
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
while (index < length) {
// ignore the hash value is required to determine the true index

View File

@ -162,7 +162,7 @@ JSTaggedValue ContainersQueue::ForEach(EcmaRuntimeCallInfo *argv)
JSHandle<JSTaggedValue>(thread, queue->Get(thread, index));
index = queue->GetNextPosition(index);
key.Update(JSTaggedValue(k));
const int32_t argsLength = 3;
const uint32_t argsLength = 3;
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);

View File

@ -431,7 +431,7 @@ JSTaggedValue ContainersTreeMap::ForEach(EcmaRuntimeCallInfo *argv)
JSHandle<TaggedArray> entries = TaggedTreeMap::GetArrayFromMap(thread, iteratedMap);
int index = 0;
size_t length = entries->GetLength();
const int32_t argsLength = 3;
const uint32_t argsLength = 3;
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
JSMutableHandle<JSTaggedValue> value(thread, JSTaggedValue::Undefined());

View File

@ -382,7 +382,7 @@ JSTaggedValue ContainersTreeSet::ForEach(EcmaRuntimeCallInfo *argv)
JSHandle<TaggedArray> entries = TaggedTreeSet::GetArrayFromSet(thread, iteratedSet);
int index = 0;
size_t length = entries->GetLength();
const int32_t argsLength = 3;
const uint32_t argsLength = 3;
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
while (index < elements) {

View File

@ -54,7 +54,7 @@ bool HeapProfiler::DumpHeapSnapshot(DumpFormat dumpFormat, Stream *stream, Progr
LOG_ECMA(INFO) << "HeapProfiler DumpSnapshot start";
size_t heapSize = vm_->GetHeap()->GetHeapObjectSize();
LOG_ECMA(ERROR) << "HeapProfiler DumpSnapshot heap size " << heapSize;
int32_t heapCount = vm_->GetHeap()->GetHeapObjectCount();
int32_t heapCount = static_cast<int32_t>(vm_->GetHeap()->GetHeapObjectCount());
if (progress != nullptr) {
progress->ReportProgress(0, heapCount);
}
@ -111,7 +111,7 @@ bool HeapProfiler::StopHeapTracking(Stream *stream, Progress *progress, bool new
if (heapTracker_ == nullptr) {
return false;
}
int32_t heapCount = vm_->GetHeap()->GetHeapObjectCount();
int32_t heapCount = static_cast<int32_t>(vm_->GetHeap()->GetHeapObjectCount());
const_cast<EcmaVM *>(vm_)->StopHeapTracking();
if (newThread) {

View File

@ -216,22 +216,22 @@ public:
return timeStampUs_;
}
int32_t GetSize() const
uint32_t GetSize() const
{
return size_;
}
void SetSize(int32_t size)
void SetSize(uint32_t size)
{
size_ = size;
}
int32_t GetCount() const
uint32_t GetCount() const
{
return count_;
}
void SetCount(int32_t count)
void SetCount(uint32_t count)
{
count_ = count;
}
@ -247,8 +247,8 @@ private:
int lastSequenceId_ {0};
int64_t timeStampUs_ {0};
int32_t size_ {0};
int32_t count_ {0};
uint32_t size_ {0};
uint32_t count_ {0};
};
class HeapEntryMap {

View File

@ -156,9 +156,9 @@ public:
}
}
inline void SetCallArg(int32_t argsLength, const TaggedArray* args)
inline void SetCallArg(uint32_t argsLength, const TaggedArray* args)
{
for (int32_t i = 0; i < argsLength; i++) {
for (uint32_t i = 0; i < argsLength; i++) {
SetCallArg(i, args->Get(GetThread(), i));
}
}

View File

@ -46,7 +46,7 @@ public:
JSHandle<JSTaggedValue> job(thread, pendingJob->GetJob());
ASSERT(job->IsCallable());
JSHandle<TaggedArray> argv(thread, pendingJob->GetArguments());
const int32_t argsLength = static_cast<int32_t>(argv->GetLength());
const uint32_t argsLength = argv->GetLength();
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, job, undefined, undefined, argsLength);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);

View File

@ -31,8 +31,8 @@ JSTaggedValue JSAPILightWeightMap::IncreaseCapacityTo(JSThread *thread,
const JSHandle<JSAPILightWeightMap> &lightWeightMap,
int32_t index)
{
int32_t num = lightWeightMap->GetSize();
if (index < DEFAULT_CAPACITY_LENGTH || num >= index) {
uint32_t num = lightWeightMap->GetSize();
if (index < DEFAULT_CAPACITY_LENGTH || static_cast<int32_t>(num) >= index) {
return JSTaggedValue::False();
}
JSHandle<TaggedArray> hashArray = GetArrayByKind(thread, lightWeightMap, AccossorsKind::HASH);
@ -51,7 +51,7 @@ void JSAPILightWeightMap::InsertValue(const JSThread *thread, const JSHandle<JSA
int32_t index, const JSHandle<JSTaggedValue> &value, AccossorsKind kind)
{
JSHandle<TaggedArray> array = GetArrayByKind(thread, lightWeightMap, kind);
int32_t len = lightWeightMap->GetSize();
uint32_t len = lightWeightMap->GetSize();
JSHandle<TaggedArray> newArray = GrowCapacity(thread, array, len + 1);
TaggedArray::InsertElementByIndex(thread, newArray, value, index, len);
SetArrayByKind(thread, lightWeightMap, newArray, kind);
@ -61,7 +61,7 @@ void JSAPILightWeightMap::ReplaceValue(const JSThread *thread, const JSHandle<JS
int32_t index, const JSHandle<JSTaggedValue> &value, AccossorsKind kind)
{
JSHandle<TaggedArray> array = GetArrayByKind(thread, lightWeightMap, kind);
ASSERT(0 <= index || index < lightWeightMap->GetSize());
ASSERT(0 <= index || index < static_cast<int32_t>(lightWeightMap->GetSize()));
array->Set(thread, index, value.GetTaggedValue());
}
@ -104,8 +104,8 @@ JSTaggedValue JSAPILightWeightMap::Get(JSThread *thread, const JSHandle<JSAPILig
JSTaggedValue JSAPILightWeightMap::HasAll(JSThread *thread, const JSHandle<JSAPILightWeightMap> &lightWeightMap,
const JSHandle<JSAPILightWeightMap> &newLightWeightMap)
{
int32_t length = newLightWeightMap->GetSize();
int32_t len = lightWeightMap->GetSize();
uint32_t length = newLightWeightMap->GetSize();
uint32_t len = lightWeightMap->GetSize();
if (length > len) {
return JSTaggedValue::False();
}
@ -118,11 +118,11 @@ JSTaggedValue JSAPILightWeightMap::HasAll(JSThread *thread, const JSHandle<JSAPI
int32_t index = -1;
int32_t hash = 0;
for (int32_t num = 0; num < length; num++) {
for (uint32_t num = 0; num < length; num++) {
dealKey = newKeyArray->Get(num);
hash = Hash(dealKey);
index = BinarySearchHashes(oldHashArray, hash, len);
if (index < 0 || index >= len) {
index = BinarySearchHashes(oldHashArray, hash, static_cast<int32_t>(len));
if (index < 0 || index >= static_cast<int32_t>(len)) {
return JSTaggedValue::False();
}
HashParams params { oldHashArray, oldKeyArray, &dealKey };
@ -147,8 +147,8 @@ JSTaggedValue JSAPILightWeightMap::HasValue(JSThread *thread, const JSHandle<JSA
const JSHandle<JSTaggedValue> &value)
{
JSHandle<TaggedArray> valueArray = GetArrayByKind(thread, lightWeightMap, AccossorsKind::VALUE);
int32_t length = lightWeightMap->GetSize();
for (int32_t num = 0; num < length; num++) {
uint32_t length = lightWeightMap->GetSize();
for (uint32_t num = 0; num < length; num++) {
if (JSTaggedValue::SameValue(valueArray->Get(num), value.GetTaggedValue())) {
return JSTaggedValue::True();
}
@ -167,7 +167,7 @@ KeyState JSAPILightWeightMap::GetStateOfKey(JSThread *thread, const JSHandle<JSA
const JSHandle<JSTaggedValue> &key)
{
int32_t hash = Hash(key.GetTaggedValue());
int32_t length = lightWeightMap->GetSize();
int32_t length = static_cast<int32_t>(lightWeightMap->GetSize());
JSHandle<TaggedArray> hashArray = GetArrayByKind(thread, lightWeightMap, AccossorsKind::HASH);
int32_t index = BinarySearchHashes(hashArray, hash, length);
if (index >= 0) {
@ -196,9 +196,9 @@ int32_t JSAPILightWeightMap::GetIndexOfValue(JSThread *thread, const JSHandle<JS
const JSHandle<JSTaggedValue> &value)
{
JSHandle<TaggedArray> valueArray = GetArrayByKind(thread, lightWeightMap, AccossorsKind::VALUE);
int32_t length = lightWeightMap->GetSize();
uint32_t length = lightWeightMap->GetSize();
JSTaggedValue compValue = value.GetTaggedValue();
for (int32_t i = 0; i < length; i++) {
for (uint32_t i = 0; i < length; i++) {
if (valueArray->Get(i) == compValue) {
return i;
}
@ -209,7 +209,7 @@ int32_t JSAPILightWeightMap::GetIndexOfValue(JSThread *thread, const JSHandle<JS
JSTaggedValue JSAPILightWeightMap::GetKeyAt(JSThread *thread, const JSHandle<JSAPILightWeightMap> &lightWeightMap,
int32_t index)
{
int32_t length = lightWeightMap->GetSize();
int32_t length = static_cast<int32_t>(lightWeightMap->GetSize());
if (index < 0 || length <= index) {
std::ostringstream oss;
oss << "The value of \"index\" is out of range. It must be >= 0 && <= " << (length - 1)
@ -224,7 +224,7 @@ JSTaggedValue JSAPILightWeightMap::GetKeyAt(JSThread *thread, const JSHandle<JSA
JSTaggedValue JSAPILightWeightMap::GetValueAt(JSThread *thread, const JSHandle<JSAPILightWeightMap> &lightWeightMap,
int32_t index)
{
int32_t length = lightWeightMap->GetSize();
int32_t length = static_cast<int32_t>(lightWeightMap->GetSize());
if (index < 0 || length <= index) {
std::ostringstream oss;
oss << "The value of \"index\" is out of range. It must be >= 0 && <= " << (length - 1)
@ -243,8 +243,8 @@ void JSAPILightWeightMap::SetAll(JSThread *thread, const JSHandle<JSAPILightWeig
JSHandle<TaggedArray> needValueArray = GetArrayByKind(thread, needLightWeightMap, AccossorsKind::VALUE);
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
JSMutableHandle<JSTaggedValue> value(thread, JSTaggedValue::Undefined());
int32_t length = needLightWeightMap->GetSize();
for (int32_t num = 0; num < length; num++) {
uint32_t length = needLightWeightMap->GetSize();
for (uint32_t num = 0; num < length; num++) {
key.Update(needKeyArray->Get(num));
value.Update(needValueArray->Get(num));
JSAPILightWeightMap::Set(thread, lightWeightMap, key, value);
@ -271,8 +271,8 @@ JSTaggedValue JSAPILightWeightMap::Remove(JSThread *thread, const JSHandle<JSAPI
JSTaggedValue JSAPILightWeightMap::RemoveAt(JSThread *thread,
const JSHandle<JSAPILightWeightMap> &lightWeightMap, int32_t index)
{
int32_t length = lightWeightMap->GetSize();
if (index < 0 || length <= index) {
uint32_t length = lightWeightMap->GetSize();
if (index < 0 || static_cast<int32_t>(length) <= index) {
return JSTaggedValue::False();
}
RemoveValue(thread, lightWeightMap, index, AccossorsKind::HASH);
@ -306,7 +306,7 @@ void JSAPILightWeightMap::Clear(JSThread *thread, const JSHandle<JSAPILightWeigh
JSTaggedValue JSAPILightWeightMap::SetValueAt(JSThread *thread, const JSHandle<JSAPILightWeightMap> &lightWeightMap,
int32_t index, const JSHandle<JSTaggedValue> &value)
{
int32_t length = lightWeightMap->GetSize();
int32_t length = static_cast<int32_t>(lightWeightMap->GetSize());
if (index < 0 || length <= index) {
std::ostringstream oss;
oss << "The value of \"index\" is out of range. It must be >= 0 && <= " << (length - 1)
@ -318,10 +318,10 @@ JSTaggedValue JSAPILightWeightMap::SetValueAt(JSThread *thread, const JSHandle<J
return JSTaggedValue::True();
}
int32_t JSAPILightWeightMap::AvoidHashCollision(HashParams &params, int32_t index, int32_t size, int32_t hash)
int32_t JSAPILightWeightMap::AvoidHashCollision(HashParams &params, int32_t index, uint32_t size, int32_t hash)
{
int32_t right = index;
while ((right < size) && ((params.hashArray)->Get(right).GetInt() == hash)) {
while ((right < static_cast<int32_t>(size)) && ((params.hashArray)->Get(right).GetInt() == hash)) {
if (JSTaggedValue::SameValue((params.keyArray)->Get(right), *(params.key))) {
return right;
}

View File

@ -82,9 +82,9 @@ public:
const JSHandle<JSTaggedValue> &key,
PropertyDescriptor &desc);
JSTaggedValue IsEmpty();
inline int32_t GetSize() const
inline uint32_t GetSize() const
{
return static_cast<int32_t>(GetLength());
return GetLength();
}
static constexpr size_t LWP_HASHES_OFFSET = JSObject::SIZE;
@ -118,7 +118,7 @@ private:
static JSHandle<TaggedArray> GetArrayByKind(const JSThread *thread,
const JSHandle<JSAPILightWeightMap> &lightWeightMap,
AccossorsKind kind);
static int32_t AvoidHashCollision(HashParams &params, int32_t index, int32_t size, int32_t hash);
static int32_t AvoidHashCollision(HashParams &params, int32_t index, uint32_t size, int32_t hash);
};
} // namespace panda::ecmascript

View File

@ -18,6 +18,7 @@
#include "ecmascript/base/builtins_base.h"
#include "ecmascript/ecma_macros.h"
#include "ecmascript/ecma_vm.h"
#include "ecmascript/mem/barriers-inl.h"
#include "ecmascript/object_factory.h"
#include "ecmascript/platform/os.h"
#include "ecmascript/tagged_array.h"

View File

@ -407,9 +407,9 @@ size_t Heap::GetHeapObjectSize() const
return result;
}
int32_t Heap::GetHeapObjectCount() const
uint32_t Heap::GetHeapObjectCount() const
{
int32_t count = 0;
uint32_t count = 0;
sweeper_->EnsureAllTaskFinished();
this->IterateOverObjects([&count]([[maybe_unused]] TaggedObject *obj) {
++count;

View File

@ -356,7 +356,7 @@ public:
inline size_t GetHeapObjectSize() const;
inline int32_t GetHeapObjectCount() const;
inline uint32_t GetHeapObjectCount() const;
size_t GetPromotedSize() const
{