ISA Optimizated for string's tag

Signed-off-by: DaiHN <daihuina1@huawei.com>
This commit is contained in:
DaiHN
2021-09-24 10:25:00 +08:00
parent 54ea82e874
commit dcdb3370fb
4 changed files with 15 additions and 14 deletions
@@ -144,7 +144,8 @@ Program *PandaFileTranslator::GenerateProgram(const panda_file::File &pf)
if (value.GetConstpoolType() == ConstPoolType::STRING) {
panda_file::File::EntityId id(it.first);
auto foundStr = pf.GetStringData(id);
auto string = factory_->GetRawStringFromStringTable(foundStr.data, foundStr.utf16_length);
auto string = factory_->GetRawStringFromStringTable(foundStr.data,
foundStr.utf16_length, foundStr.is_ascii);
constpool->Set(thread_, value.GetConstpoolIndex(), JSTaggedValue(string));
} else if (value.GetConstpoolType() == ConstPoolType::BASE_FUNCTION) {
ASSERT(mainMethodIndex_ != it.first);
+8 -9
View File
@@ -45,8 +45,8 @@ void LiteralDataExtractor::ExtractObjectDatas(JSThread *thread, const panda_file
uint32_t methodId;
FunctionKind kind;
lda.EnumerateLiteralVals(
index, [elements, properties, &epos, &ppos, factory, thread, pft, &methodId, &kind](const LiteralValue &value,
const LiteralTag &tag) {
index, [elements, properties, &epos, &ppos, factory, thread, pft, pf, &methodId, &kind]
(const LiteralValue &value, const LiteralTag &tag) {
JSTaggedValue jt = JSTaggedValue::Null();
bool flag = false;
switch (tag) {
@@ -63,8 +63,8 @@ void LiteralDataExtractor::ExtractObjectDatas(JSThread *thread, const panda_file
break;
}
case LiteralTag::STRING: {
StringData sd = std::get<StringData>(value);
EcmaString *str = factory->GetRawStringFromStringTable(sd.data, sd.utf16_length);
StringData sd = pf->GetStringData(panda_file::File::EntityId(std::get<uint32_t>(value)));
EcmaString *str = factory->GetRawStringFromStringTable(sd.data, sd.utf16_length, sd.is_ascii);
jt = JSTaggedValue(str);
uint32_t index = 0;
if (JSTaggedValue::ToElementIndex(jt, &index) && ppos % pairSize == 0) {
@@ -129,9 +129,8 @@ JSHandle<TaggedArray> LiteralDataExtractor::GetDatasIgnoreType(JSThread *thread,
uint32_t methodId;
FunctionKind kind;
lda.EnumerateLiteralVals(
index, [literals, &pos, factory, thread, pft,
&methodId, &kind](const panda_file::LiteralDataAccessor::LiteralValue &value,
const LiteralTag &tag) {
index, [literals, &pos, factory, thread, pft, pf, &methodId, &kind]
(const panda_file::LiteralDataAccessor::LiteralValue &value, const LiteralTag &tag) {
JSTaggedValue jt = JSTaggedValue::Null();
switch (tag) {
case LiteralTag::INTEGER: {
@@ -147,8 +146,8 @@ JSHandle<TaggedArray> LiteralDataExtractor::GetDatasIgnoreType(JSThread *thread,
break;
}
case LiteralTag::STRING: {
StringData sd = std::get<StringData>(value);
EcmaString *str = factory->GetRawStringFromStringTable(sd.data, sd.utf16_length);
StringData sd = pf->GetStringData(panda_file::File::EntityId(std::get<uint32_t>(value)));
EcmaString *str = factory->GetRawStringFromStringTable(sd.data, sd.utf16_length, sd.is_ascii);
jt = JSTaggedValue(str);
break;
}
+4 -3
View File
@@ -1728,13 +1728,14 @@ JSHandle<EcmaString> ObjectFactory::GetStringFromStringTable(EcmaString *string)
}
// NB! don't do special case for C0 80, it means '\u0000', so don't convert to UTF-8
EcmaString *ObjectFactory::GetRawStringFromStringTable(const uint8_t *mutf8Data, uint32_t utf16Len) const
EcmaString *ObjectFactory::GetRawStringFromStringTable(const uint8_t *mutf8Data,
uint32_t utf16Len, bool canBeCompressed) const
{
if (UNLIKELY(utf16Len == 0)) {
return *GetEmptyString();
}
if (utf::IsMUtf8OnlySingleBytes(mutf8Data)) {
if (canBeCompressed) {
return EcmaString::Cast(vm_->GetEcmaStringTable()->GetOrInternString(mutf8Data, utf16Len, true));
}
@@ -2102,7 +2103,7 @@ EcmaString *ObjectFactory::ResolveString(uint32_t stringId)
auto id = panda_file::File::EntityId(stringId);
auto foundStr = pf->GetStringData(id);
return GetRawStringFromStringTable(foundStr.data, foundStr.utf16_length);
return GetRawStringFromStringTable(foundStr.data, foundStr.utf16_length, foundStr.is_ascii);
}
uintptr_t ObjectFactory::NewSpaceBySnapShotAllocator(size_t size)
+1 -1
View File
@@ -447,7 +447,7 @@ private:
JSHandle<EcmaString> GetStringFromStringTable(const uint8_t *utf8Data, uint32_t utf8Len, bool canBeCompress) const;
// For MUtf-8 string data
EcmaString *GetRawStringFromStringTable(const uint8_t *mutf8Data, uint32_t utf16Len) const;
EcmaString *GetRawStringFromStringTable(const uint8_t *mutf8Data, uint32_t utf16Len, bool canBeCompressed) const;
JSHandle<EcmaString> GetStringFromStringTable(const uint16_t *utf16Data, uint32_t utf16Len,
bool canBeCompress) const;