Fix ldobjbyvalue crash in aot code when array is undefined

Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAD9CG

Signed-off-by: c00513733 <chenqiuyao@huawei.com>
Change-Id: If66e24f7d77d4b4b6547dc5c336bed3a2cc0a11d
This commit is contained in:
c00513733 2024-07-16 11:00:17 +08:00
parent 9baa81aedc
commit 8742a10cb2
3 changed files with 17 additions and 0 deletions

View File

@ -407,6 +407,7 @@ void TypedHCRLowering::LowerTypedArrayCheck(GateRef gate)
GateRef frameState = GetFrameState(gate);
GateRef glueGlobalEnv = builder_.GetGlobalEnv();
GateRef receiver = acc_.GetValueIn(gate, 0);
builder_.HeapObjectCheck(receiver, frameState);
GateRef receiverHClass = builder_.LoadHClass(receiver);
GateRef rootHclass = builder_.GetGlobalEnvObj(glueGlobalEnv, typedArrayRootHclassIndex);
GateRef rootOnHeapHclass = builder_.GetGlobalEnvObj(glueGlobalEnv, typedArrayRootHclassOnHeapIndex);

View File

@ -13,3 +13,4 @@
number
boolean
testTypedArrayUsedAsUndefined success

View File

@ -30,3 +30,18 @@ let b = new B(1);
b.x = 1 < 2
print(typeof b.x)
function callback(a1, a2, a3, a4) {
a4[a2] &= 1;
const arr2 = new Array(a3);
try {
arr2.find(callback);
} catch (e) { }
}
function testTypedArrayUsedAsUndefined() {
const arr = new Float32Array(20);
arr.reduceRight(callback);
print("testTypedArrayUsedAsUndefined success");
}
testTypedArrayUsedAsUndefined();