mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Convert properties value to match attr rep in CreateObjectFromProperties
Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAGE45 Reason:the value in const pool not match with hclass Description:when JSObject::CreateObjectFromProperties, the object literal value not match with attr's rep Signed-off-by: huanghuijin <huanghuijin@huawei.com>
This commit is contained in:
parent
39c011cc97
commit
cd95704bf5
@ -2334,7 +2334,8 @@ void TypedBytecodeLowering::LowerCreateObjectWithBuffer(GateRef gate)
|
||||
if (!converted.first) {
|
||||
return;
|
||||
}
|
||||
inlinedProps.emplace_back(converted.second.GetRawData());
|
||||
// CanOptimize.GetObject had convert value, just used directly
|
||||
inlinedProps.emplace_back(value.GetRawData());
|
||||
} else if (compilationEnv_ != nullptr && compilationEnv_->IsJitCompiler() && value.IsString()) {
|
||||
inlinedProps.emplace_back(value.GetRawData());
|
||||
} else {
|
||||
|
@ -2711,13 +2711,24 @@ JSHandle<JSObject> JSObject::CreateObjectFromProperties(const JSThread *thread,
|
||||
propsLen++;
|
||||
}
|
||||
if (propsLen <= PropertyAttributes::MAX_FAST_PROPS_CAPACITY) {
|
||||
JSHandle<JSHClass> hclass;
|
||||
bool isLiteral = false;
|
||||
if (ihcVal.IsJSHClass()) {
|
||||
auto hclass = JSHandle<JSHClass>(thread, ihcVal);
|
||||
hclass = JSHandle<JSHClass>(thread, ihcVal);
|
||||
} else {
|
||||
hclass = factory->GetObjectLiteralHClass(properties, propsLen);
|
||||
isLiteral = true;
|
||||
}
|
||||
if (hclass->IsTS()) {
|
||||
if (CheckPropertiesForRep(properties, propsLen, hclass)) {
|
||||
return CreateObjectFromPropertiesByIHClass(thread, properties, propsLen, hclass);
|
||||
} else if (!isLiteral) {
|
||||
hclass = factory->GetObjectLiteralHClass(properties, propsLen);
|
||||
// if check failed, get literal object again
|
||||
return CreateObjectFromPropertiesByIHClass(thread, properties, propsLen, hclass);
|
||||
}
|
||||
}
|
||||
return CreateObjectFromProperties(thread, properties, propsLen);
|
||||
return CreateObjectFromProperties(thread, hclass, properties, propsLen);
|
||||
} else {
|
||||
JSHandle<JSObject> obj = factory->NewEmptyJSObject(0); // 0: no inline field
|
||||
JSHClass::TransitionToDictionary(thread, obj);
|
||||
@ -2741,11 +2752,11 @@ JSHandle<JSObject> JSObject::CreateObjectFromProperties(const JSThread *thread,
|
||||
}
|
||||
|
||||
JSHandle<JSObject> JSObject::CreateObjectFromProperties(const JSThread *thread,
|
||||
const JSHandle<JSHClass> &hclass,
|
||||
const JSHandle<TaggedArray> &properties,
|
||||
uint32_t propsLen)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
auto hclass = factory->GetObjectLiteralHClass(properties, propsLen);
|
||||
JSHandle<JSObject> obj = factory->NewOldSpaceObjLiteralByHClass(hclass);
|
||||
ASSERT_PRINT(obj->IsECMAObject(), "Obj is not a valid object");
|
||||
|
||||
|
@ -656,6 +656,7 @@ public:
|
||||
const JSHandle<TaggedArray> &properties,
|
||||
JSTaggedValue ihc = JSTaggedValue::Undefined());
|
||||
static JSHandle<JSObject> CreateObjectFromProperties(const JSThread *thread,
|
||||
const JSHandle<JSHClass> &hclass,
|
||||
const JSHandle<TaggedArray> &properties,
|
||||
uint32_t propsLen);
|
||||
static JSHandle<JSObject> CreateObjectFromPropertiesByIHClass(const JSThread *thread,
|
||||
|
@ -41,3 +41,14 @@ class A {
|
||||
|
||||
let a = new A();
|
||||
a.Measure();
|
||||
|
||||
const o46 = {
|
||||
3503: 4096,
|
||||
"maxByteLength": 4096,
|
||||
};
|
||||
|
||||
const o48 = {
|
||||
"maxByteLength": 3012855560,
|
||||
};
|
||||
|
||||
print(o46[3503]);
|
||||
|
@ -14,3 +14,4 @@
|
||||
1
|
||||
str
|
||||
11.1
|
||||
4096
|
||||
|
Loading…
Reference in New Issue
Block a user