mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
!4310 Optimize StownByName instruction
Merge pull request !4310 from 吴璋达/ownname
This commit is contained in:
commit
43e3fd22a2
@ -56,6 +56,10 @@ void NTypeHCRLowering::Lower(GateRef gate)
|
||||
case EcmaOpcode::WIDE_STOWNBYINDEX_PREF_V8_IMM32:
|
||||
LowerTypedStownByIndex(gate);
|
||||
break;
|
||||
case EcmaOpcode::STOWNBYNAME_IMM8_ID16_V8:
|
||||
case EcmaOpcode::STOWNBYNAME_IMM16_ID16_V8:
|
||||
LowerTypedStOwnByName(gate);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -90,6 +94,42 @@ void NTypeHCRLowering::LowerTypedStownByIndex(GateRef gate)
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), Circuit::NullGate());
|
||||
}
|
||||
|
||||
void NTypeHCRLowering::LowerTypedStOwnByName(GateRef gate)
|
||||
{
|
||||
// 3: number of value inputs
|
||||
ASSERT(acc_.GetNumValueIn(gate) == 3);
|
||||
auto constData = acc_.GetValueIn(gate, 0);
|
||||
uint16_t propIndex = acc_.GetConstantValue(constData);
|
||||
auto thread = tsManager_->GetEcmaVM()->GetJSThread();
|
||||
auto propKey = tsManager_->GetStringFromConstantPool(propIndex);
|
||||
|
||||
GateRef receiver = acc_.GetValueIn(gate, 1);
|
||||
GateRef value = acc_.GetValueIn(gate, 2);
|
||||
|
||||
GateType receiverType = acc_.GetGateType(receiver);
|
||||
receiverType = tsManager_->TryNarrowUnionType(receiverType);
|
||||
|
||||
int hclassIndex = -1;
|
||||
if (tsManager_->IsObjectTypeKind(receiverType)) {
|
||||
hclassIndex = tsManager_->GetHClassIndexByObjectType(receiverType);
|
||||
}
|
||||
if (hclassIndex == -1) { // slowpath
|
||||
return;
|
||||
}
|
||||
JSHClass *hclass = JSHClass::Cast(tsManager_->GetHClassFromCache(hclassIndex).GetTaggedObject());
|
||||
|
||||
PropertyLookupResult plr = JSHClass::LookupPropertyInAotHClass(thread, hclass, propKey);
|
||||
if (!plr.IsFound() || !plr.IsLocal() || plr.IsAccessor() || !plr.IsWritable()) { // slowpath
|
||||
return;
|
||||
}
|
||||
AddProfiling(gate);
|
||||
|
||||
GateRef pfrGate = builder_.Int32(plr.GetData());
|
||||
builder_.StoreProperty(receiver, pfrGate, value);
|
||||
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), Circuit::NullGate());
|
||||
}
|
||||
|
||||
void NTypeHCRLowering::AddProfiling(GateRef gate)
|
||||
{
|
||||
if (IsTraceBC()) {
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
void Lower(GateRef gate);
|
||||
void LowerTypedCreateEmptyArray(GateRef gate);
|
||||
void LowerTypedStownByIndex(GateRef gate);
|
||||
void LowerTypedStOwnByName(GateRef gate);
|
||||
|
||||
bool IsLogEnabled() const
|
||||
{
|
||||
|
@ -87,6 +87,10 @@ void PGOTypeInfer::RunTypeInfer(GateRef gate)
|
||||
case EcmaOpcode::STTHISBYNAME_IMM16_ID16:
|
||||
InferStObjByName(gate, true);
|
||||
break;
|
||||
case EcmaOpcode::STOWNBYNAME_IMM8_ID16_V8:
|
||||
case EcmaOpcode::STOWNBYNAME_IMM16_ID16_V8:
|
||||
InferStOwnByName(gate);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -288,6 +292,21 @@ void PGOTypeInfer::InferStObjByName(GateRef gate, bool isThis)
|
||||
UpdateTypeForRWOp(gate, receiver, prop);
|
||||
}
|
||||
|
||||
void PGOTypeInfer::InferStOwnByName(GateRef gate)
|
||||
{
|
||||
if (!builder_->ShouldPGOTypeInfer(gate)) {
|
||||
return;
|
||||
}
|
||||
// 3: number of value inputs
|
||||
ASSERT(acc_.GetNumValueIn(gate) == 3);
|
||||
GateRef constData = acc_.GetValueIn(gate, 0);
|
||||
uint16_t propIndex = acc_.GetConstantValue(constData);
|
||||
JSTaggedValue prop = tsManager_->GetStringFromConstantPool(propIndex);
|
||||
GateRef receiver = acc_.GetValueIn(gate, 1);
|
||||
|
||||
UpdateTypeForRWOp(gate, receiver, prop);
|
||||
}
|
||||
|
||||
void PGOTypeInfer::UpdateTypeForRWOp(GateRef gate, GateRef receiver, JSTaggedValue prop)
|
||||
{
|
||||
GateType tsType = acc_.GetGateType(receiver);
|
||||
|
@ -67,6 +67,7 @@ private:
|
||||
void RunTypeInfer(GateRef gate);
|
||||
void InferLdObjByName(GateRef gate);
|
||||
void InferStObjByName(GateRef gate, bool isThis);
|
||||
void InferStOwnByName(GateRef gate);
|
||||
|
||||
void UpdateTypeForRWOp(GateRef gate, GateRef receiver, JSTaggedValue prop);
|
||||
void CollectGateType(CollectedType &types, GateType tsType, PGORWOpType pgoTypes);
|
||||
|
@ -13,3 +13,5 @@
|
||||
|
||||
a
|
||||
b
|
||||
100
|
||||
helloworld
|
||||
|
@ -18,4 +18,37 @@ var foo = {
|
||||
bar: [ "a", "b" ]
|
||||
};
|
||||
print(foo.bar[0]);
|
||||
print(foo.bar[1]);
|
||||
print(foo.bar[1]);
|
||||
|
||||
interface objInterface {
|
||||
[key: string]: any
|
||||
}
|
||||
let obj:objInterface = {};
|
||||
obj.a = 100;
|
||||
obj.b = "helloworld";
|
||||
print(obj.a)
|
||||
print(obj.b);
|
||||
|
||||
function ArkFunc(depth: number, tag: string): {
|
||||
array: number[],
|
||||
string: string
|
||||
} | {
|
||||
left: object,
|
||||
right: object
|
||||
} {
|
||||
if (depth == 0) {
|
||||
return {
|
||||
array: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||
string: 'Ark ' + tag + ' Departure!'
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
left: ArkFunc(depth - 1, tag),
|
||||
right: ArkFunc(depth - 1, tag)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var arkDepth: number = 5;
|
||||
var arkTag: number = 18;
|
||||
var arkResult = ArkFunc(arkDepth, String(arkTag));
|
Loading…
Reference in New Issue
Block a user