!7663 opt callruntime IsElementsKindSwitchOn

Merge pull request !7663 from wpy111/master
This commit is contained in:
openharmony_ci 2024-06-05 06:53:41 +00:00 committed by Gitee
commit 7b8fbc7cd1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 21 additions and 18 deletions

View File

@ -76,8 +76,8 @@ GateRef NewObjectStubBuilder::NewJSArrayWithSize(GateRef hclass, GateRef size)
Label enabledElementsKind(env);
Label notEmptyArray(env);
Label initObj(env);
GateRef isElementsKindEnabled = CallRuntime(glue_, RTSTUB_ID(IsElementsKindSwitchOn), {});
BRANCH(TaggedIsTrue(isElementsKindEnabled), &enabledElementsKind, &initObj);
GateRef isElementsKindEnabled = IsEnableElementsKind(glue_);
BRANCH(isElementsKindEnabled, &enabledElementsKind, &initObj);
Bind(&enabledElementsKind);
{
// For new Array(Len), the elementsKind should be Hole

View File

@ -3176,6 +3176,12 @@ inline GateRef StubBuilder::GetSingleCharTable(GateRef glue)
VariableType::JS_POINTER(), glue, ConstantIndex::SINGLE_CHAR_TABLE_INDEX);
}
inline GateRef StubBuilder::IsEnableElementsKind(GateRef glue)
{
GateRef offset = IntPtr(JSThread::GlueData::GetIsEnableElementsKindOffset(env_->Is32Bit()));
return Load(VariableType::BOOL(), glue, offset);
}
inline GateRef StubBuilder::GetGlobalEnvValue(VariableType type, GateRef env, size_t index)
{
auto valueIndex = IntPtr(GlobalEnv::HEADER_SIZE + JSTaggedValue::TaggedTypeSize() * index);

View File

@ -10315,8 +10315,8 @@ void StubBuilder::MigrateArrayWithKind(GateRef glue, GateRef object, GateRef old
Label exit(env);
Label elementsKindOn(env);
GateRef isElementsKindSwitchOn = CallRuntime(glue, RTSTUB_ID(IsElementsKindSwitchOn), {});
BRANCH(TaggedIsTrue(isElementsKindSwitchOn), &elementsKindOn, &exit);
GateRef isElementsKindEnabled = IsEnableElementsKind(glue);
BRANCH(isElementsKindEnabled, &elementsKindOn, &exit);
Bind(&elementsKindOn);
DEFVARIABLE(newElements, VariableType::JS_ANY(), Undefined());

View File

@ -847,6 +847,7 @@ public:
inline GateRef GetGlobalConstantValue(
VariableType type, GateRef glue, ConstantIndex index);
inline GateRef GetSingleCharTable(GateRef glue);
inline GateRef IsEnableElementsKind(GateRef glue);
inline GateRef GetGlobalEnvValue(VariableType type, GateRef env, size_t index);
GateRef CallGetterHelper(
GateRef glue, GateRef receiver, GateRef holder, GateRef accessor, ProfileOperation callback);

View File

@ -322,9 +322,6 @@ bool EcmaVM::IsEnablePGOProfiler() const
bool EcmaVM::IsEnableElementsKind() const
{
if (options_.IsWorker()) {
return false;
}
return options_.GetEnableAsmInterpreter() && options_.IsEnableElementsKind();
}

View File

@ -102,6 +102,7 @@ JSThread *JSThread::Create(EcmaVM *vm)
jsThread->glueData_.stackLimit_ = GetAsmStackLimit();
jsThread->glueData_.stackStart_ = GetCurrentStackPosition();
jsThread->glueData_.isEnableElementsKind_ = vm->IsEnableElementsKind();
jsThread->SetThreadId();
RegisterThread(jsThread);

View File

@ -946,7 +946,8 @@ public:
base::AlignedPointer,
base::AlignedPointer,
base::AlignedPointer,
base::AlignedUint32> {
base::AlignedUint32,
base::AlignedBool> {
enum class Index : size_t {
BCStubEntriesIndex = 0,
ExceptionIndex,
@ -987,6 +988,7 @@ public:
RandomStatePtrIndex,
stateAndFlagsIndex,
TaskInfoIndex,
IsEnableElementsKindIndex,
NumOfMembers
};
static_assert(static_cast<size_t>(Index::NumOfMembers) == NumOfTypes);
@ -1202,6 +1204,11 @@ public:
return GetOffset<static_cast<size_t>(Index::TaskInfoIndex)>(isArch32);
}
static size_t GetIsEnableElementsKindOffset(bool isArch32)
{
return GetOffset<static_cast<size_t>(Index::IsEnableElementsKindIndex)>(isArch32);
}
alignas(EAS) BCStubEntries bcStubEntries_ {};
alignas(EAS) JSTaggedValue exception_ {JSTaggedValue::Hole()};
alignas(EAS) JSTaggedValue globalObject_ {JSTaggedValue::Hole()};
@ -1241,6 +1248,7 @@ public:
alignas(EAS) uintptr_t randomStatePtr_ {0};
alignas(EAS) ThreadStateAndFlags stateAndFlags_ {};
alignas(EAS) uintptr_t taskInfo_ {0};
alignas(EAS) bool isEnableElementsKind_ {false};
};
STATIC_ASSERT_EQ_ARCH(sizeof(GlueData), GlueData::SizeArch32, GlueData::SizeArch64);

View File

@ -618,15 +618,6 @@ DEF_RUNTIME_STUBS(CopyAndUpdateObjLayout)
return JSTaggedValue::Hole().GetRawData();
}
DEF_RUNTIME_STUBS(IsElementsKindSwitchOn)
{
RUNTIME_STUBS_HEADER(IsElementsKindSwitchOn);
if (thread->GetEcmaVM()->IsEnableElementsKind()) {
return JSTaggedValue::True().GetRawData();
}
return JSTaggedValue::False().GetRawData();
}
DEF_RUNTIME_STUBS(UpdateHClassForElementsKind)
{
RUNTIME_STUBS_HEADER(UpdateHClassForElementsKind);

View File

@ -253,7 +253,6 @@ using FastCallAotEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, co
V(UpdateLayOutAndAddTransition) \
V(CopyAndUpdateObjLayout) \
V(UpdateHClassForElementsKind) \
V(IsElementsKindSwitchOn) \
V(SetValueWithElementsKind) \
V(UpdateArrayHClassAndMigrateArrayWithKind) \
V(MigrateArrayWithKind) \