mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
ConvertValueWithRep when set property byname
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IACSY5?from=project-issue Signed-off-by: 刘智杰 <liuzhijie9@huawei.com> Change-Id: I9c8414d8d52559633de58b923bca72e21d696415
This commit is contained in:
parent
b10b6d5f17
commit
31630f33c9
@ -344,6 +344,7 @@ template<ObjectFastOperator::Status status>
|
||||
JSTaggedValue ObjectFastOperator::TrySetPropertyByNameThroughCacheAtLocal(JSThread *thread, JSTaggedValue receiver,
|
||||
JSTaggedValue key, JSTaggedValue value)
|
||||
{
|
||||
bool isTagged = true;
|
||||
auto *hclass = receiver.GetTaggedObject()->GetClass();
|
||||
if (LIKELY(!hclass->IsDictionaryMode())) {
|
||||
ASSERT(!TaggedArray::Cast(JSObject::Cast(receiver)->GetProperties().GetTaggedObject())->IsDictionaryMode());
|
||||
@ -374,6 +375,14 @@ JSTaggedValue ObjectFastOperator::TrySetPropertyByNameThroughCacheAtLocal(JSThre
|
||||
if (attrVal.IsHole()) {
|
||||
return JSTaggedValue::Hole();
|
||||
}
|
||||
JSHandle<JSObject> objHandle(thread, receiver);
|
||||
JSHandle<JSTaggedValue> keyHandle(thread, key);
|
||||
auto actualValue = JSHClass::ConvertOrTransitionWithRep(thread, objHandle,
|
||||
keyHandle, JSHandle<JSTaggedValue>(thread, value), attr);
|
||||
receiver = objHandle.GetTaggedValue();
|
||||
key = keyHandle.GetTaggedValue();
|
||||
value = actualValue.value;
|
||||
isTagged = actualValue.isTagged;
|
||||
}
|
||||
if (receiver.IsJSShared()) {
|
||||
if (!ClassHelper::MatchFieldType(attr.GetSharedFieldType(), value)) {
|
||||
@ -381,7 +390,11 @@ JSTaggedValue ObjectFastOperator::TrySetPropertyByNameThroughCacheAtLocal(JSThre
|
||||
JSTaggedValue::Exception());
|
||||
}
|
||||
}
|
||||
JSObject::Cast(receiver)->SetProperty(thread, hclass, attr, value);
|
||||
if (isTagged) {
|
||||
JSObject::Cast(receiver)->SetProperty<true>(thread, hclass, attr, value);
|
||||
} else {
|
||||
JSObject::Cast(receiver)->SetProperty<false>(thread, hclass, attr, value);
|
||||
}
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
}
|
||||
@ -460,7 +473,16 @@ JSTaggedValue ObjectFastOperator::SetPropertyByName(JSThread *thread, JSTaggedVa
|
||||
JSTaggedValue::Exception());
|
||||
}
|
||||
}
|
||||
JSObject::Cast(holder)->SetProperty(thread, hclass, attr, value);
|
||||
JSHandle<JSObject> objHandle(thread, receiver);
|
||||
auto actualValue = JSHClass::ConvertOrTransitionWithRep(thread, objHandle,
|
||||
JSHandle<JSTaggedValue>(thread, key), JSHandle<JSTaggedValue>(thread, value), attr);
|
||||
receiver = objHandle.GetTaggedValue();
|
||||
hclass = objHandle->GetClass();
|
||||
if (actualValue.isTagged) {
|
||||
JSObject::Cast(receiver)->SetProperty<true>(thread, hclass, attr, actualValue.value);
|
||||
} else {
|
||||
JSObject::Cast(receiver)->SetProperty<false>(thread, hclass, attr, actualValue.value);
|
||||
}
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
} else {
|
||||
@ -510,7 +532,16 @@ JSTaggedValue ObjectFastOperator::SetPropertyByName(JSThread *thread, JSTaggedVa
|
||||
auto *receiverHClass = receiver.GetTaggedObject()->GetClass();
|
||||
LayoutInfo *receiverLayoutInfo = LayoutInfo::Cast(receiverHClass->GetLayout().GetTaggedObject());
|
||||
PropertyAttributes attr(receiverLayoutInfo->GetAttr(receiverHoleEntry));
|
||||
JSObject::Cast(receiver)->SetProperty(thread, receiverHClass, attr, value);
|
||||
JSHandle<JSObject> objHandle(thread, receiver);
|
||||
auto actualValue = JSHClass::ConvertOrTransitionWithRep(thread, objHandle,
|
||||
JSHandle<JSTaggedValue>(thread, key), JSHandle<JSTaggedValue>(thread, value), attr);
|
||||
receiver = objHandle.GetTaggedValue();
|
||||
receiverHClass = objHandle->GetClass();
|
||||
if (actualValue.isTagged) {
|
||||
JSObject::Cast(receiver)->SetProperty<true>(thread, receiverHClass, attr, actualValue.value);
|
||||
} else {
|
||||
JSObject::Cast(receiver)->SetProperty<false>(thread, receiverHClass, attr, actualValue.value);
|
||||
}
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
|
||||
|
@ -22,4 +22,21 @@ var arrow_sum = (arg1:number, arg2:number):number => {
|
||||
}
|
||||
|
||||
print(arrow_func());
|
||||
print(arrow_sum(2, 3));
|
||||
print(arrow_sum(2, 3));
|
||||
|
||||
class C3 {}
|
||||
const v20 = new C3();
|
||||
const v21 = new C3();
|
||||
function f26() {
|
||||
const o39 = {
|
||||
"a": 1,
|
||||
"d": 1000000000000,
|
||||
__proto__: v21,
|
||||
toLowerCase(a32, a33, a34) {
|
||||
},
|
||||
"d": 2,
|
||||
536870889: 1,
|
||||
};
|
||||
return o39;
|
||||
}
|
||||
f26();
|
Loading…
Reference in New Issue
Block a user