mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 01:59:58 +00:00
Code security optimization
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IADBY2 Signed-off-by: hlm2001 <huanglimin10@huawei.com> Change-Id: I190f219709d65a314dccf9ebf9f6ad9e6bb56c34
This commit is contained in:
parent
3e6f83c386
commit
ba31b52a1e
@ -44,7 +44,7 @@ JSHandle<TransitionsDictionary> TransitionsDictionary::PutIfAbsent(const JSThrea
|
||||
const JSHandle<JSTaggedValue> &value,
|
||||
const JSHandle<JSTaggedValue> &metaData)
|
||||
{
|
||||
int hash = TransitionsDictionary::Hash(key.GetTaggedValue(), metaData.GetTaggedValue());
|
||||
uint32_t hash = static_cast<uint32_t>(TransitionsDictionary::Hash(key.GetTaggedValue(), metaData.GetTaggedValue()));
|
||||
|
||||
/* no need to add key if exist */
|
||||
int entry = dictionary->FindEntry(key.GetTaggedValue(), metaData.GetTaggedValue());
|
||||
@ -117,7 +117,7 @@ void TransitionsDictionary::Rehash(const JSThread *thread, TransitionsDictionary
|
||||
JSTaggedValue k = this->GetKey(i);
|
||||
JSTaggedValue v = this->GetValue(i);
|
||||
if (IsKey(k) && TransitionsDictionary::CheckWeakExist(v)) {
|
||||
int hash = TransitionsDictionary::Hash(k, this->GetAttributes(i));
|
||||
uint32_t hash = static_cast<uint32_t>(TransitionsDictionary::Hash(k, this->GetAttributes(i)));
|
||||
int insertionIndex = GetEntryIndex(newTable->FindInsertIndex(hash));
|
||||
JSTaggedValue tv = Get(fromIndex);
|
||||
newTable->Set(thread, insertionIndex, tv);
|
||||
|
@ -79,6 +79,7 @@ bool Method::IsDeoptimized() const
|
||||
uint32_t Method::FindCatchBlock(uint32_t pc) const
|
||||
{
|
||||
ASSERT(!IsNativeWithCallField());
|
||||
ASSERT(GetJSPandaFile() != nullptr);
|
||||
auto *pandaFile = GetJSPandaFile()->GetPandaFile();
|
||||
ASSERT(pandaFile != nullptr);
|
||||
panda_file::MethodDataAccessor mda(*pandaFile, GetMethodId());
|
||||
@ -99,6 +100,7 @@ uint32_t Method::FindCatchBlock(uint32_t pc) const
|
||||
|
||||
bool Method::HasCatchBlock() const
|
||||
{
|
||||
ASSERT(GetJSPandaFile() != nullptr);
|
||||
auto *pandaFile = GetJSPandaFile()->GetPandaFile();
|
||||
ASSERT(pandaFile != nullptr);
|
||||
panda_file::MethodDataAccessor mda(*pandaFile, GetMethodId());
|
||||
|
@ -34,7 +34,7 @@ JSHandle<CjsModuleCache> CjsModuleCache::PutIfAbsentAndReset(const JSThread *thr
|
||||
JSHandle<CjsModuleCache> newDictionary(HashTable::GrowHashTable(thread, dictionary));
|
||||
|
||||
// Compute the key object.
|
||||
int hash = static_cast<int>(Hash(key.GetTaggedValue()));
|
||||
uint32_t hash = Hash(key.GetTaggedValue());
|
||||
entry = newDictionary->FindInsertIndex(hash);
|
||||
newDictionary->SetEntry(thread, entry, key, value);
|
||||
newDictionary->IncreaseEntries(thread);
|
||||
|
@ -446,7 +446,7 @@ JSHandle<PointerToIndexDictionary> PointerToIndexDictionary::PutIfAbsent(
|
||||
JSHandle<PointerToIndexDictionary> newDictionary = HashTableT::GrowHashTable(thread, dictionary);
|
||||
|
||||
// Compute the key object
|
||||
int32_t hash = PointerToIndexDictionary::Hash(key.GetTaggedValue());
|
||||
uint32_t hash = static_cast<uint32_t>(PointerToIndexDictionary::Hash(key.GetTaggedValue()));
|
||||
entry = newDictionary->FindInsertIndex(hash);
|
||||
newDictionary->SetEntry(thread, entry, key.GetTaggedValue(), value.GetTaggedValue());
|
||||
newDictionary->IncreaseEntries(thread);
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
}
|
||||
|
||||
// Make sure the key object has an identity hash code.
|
||||
int32_t hash = static_cast<int32_t>(Derived::Hash(key.GetTaggedValue()));
|
||||
uint32_t hash = static_cast<uint32_t>(Derived::Hash(key.GetTaggedValue()));
|
||||
JSHandle<Derived> newTable = GrowHashTable(thread, table);
|
||||
newTable->AddElement(thread, newTable->FindInsertIndex(hash), key, value);
|
||||
return newTable;
|
||||
@ -274,7 +274,7 @@ public:
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline int FindInsertIndex(int hash)
|
||||
inline int FindInsertIndex(uint32_t hash)
|
||||
{
|
||||
int size = Size();
|
||||
int count = 1;
|
||||
@ -318,7 +318,7 @@ public:
|
||||
if (!IsKey(k)) {
|
||||
continue;
|
||||
}
|
||||
int32_t hash = static_cast<int32_t>(Derived::Hash(k));
|
||||
uint32_t hash = static_cast<uint32_t>(Derived::Hash(k));
|
||||
int insertionIndex = Derived::GetKeyIndex(newTable->FindInsertIndex(hash));
|
||||
JSTaggedValue tv = Get(fromIndex);
|
||||
newTable->Set(thread, insertionIndex, tv);
|
||||
@ -438,7 +438,7 @@ public:
|
||||
JSHandle<Derived> newTable = HashTableT::GrowHashTable(thread, table);
|
||||
|
||||
// Compute the key object.
|
||||
int32_t hash = static_cast<int32_t>(Derived::Hash(key.GetTaggedValue()));
|
||||
uint32_t hash = static_cast<uint32_t>(Derived::Hash(key.GetTaggedValue()));
|
||||
entry = newTable->FindInsertIndex(hash);
|
||||
newTable->SetEntry(thread, entry, key.GetTaggedValue(), value.GetTaggedValue(), attr);
|
||||
|
||||
@ -466,7 +466,7 @@ public:
|
||||
JSHandle<Derived> newTable = HashTableT::GrowHashTable(thread, table);
|
||||
|
||||
// Compute the key object.
|
||||
int hash = Derived::Hash(key.GetTaggedValue());
|
||||
uint32_t hash = static_cast<uint32_t>(Derived::Hash(key.GetTaggedValue()));
|
||||
entry = newTable->FindInsertIndex(hash);
|
||||
newTable->SetEntry(thread, entry, key.GetTaggedValue(), value.GetTaggedValue(), attr);
|
||||
|
||||
|
@ -333,8 +333,9 @@ HWTEST_F_L0(TemplateMapTest, FindInsertIndex)
|
||||
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
JSHandle<JSTaggedValue> tempMapKey(JSArray::ArrayCreate(thread, JSTaggedNumber(i)));
|
||||
uint32_t hashValue = static_cast<uint32_t>(TemplateMap::Hash(tempMapKey.GetTaggedValue()));
|
||||
EXPECT_EQ(JSTaggedValue::Undefined(), templateMap->GetKey(
|
||||
templateMap->FindInsertIndex(TemplateMap::Hash(tempMapKey.GetTaggedValue()))));
|
||||
templateMap->FindInsertIndex(hashValue)));
|
||||
}
|
||||
}
|
||||
} // namespace panda::test
|
||||
|
Loading…
Reference in New Issue
Block a user