Skip to content

Commit c8ae2c6

Browse files
committed
[MERGE #5732 @pleath] OSG#19011798: GlobOpt::UpdateObjPtrValueType can't distinguish typed array from virtual typed array
Merge pull request #5732 from pleath:19011798 Do not attempt to optimize the ValueType in case of typed array.
2 parents 090b258 + 5f9b9c6 commit c8ae2c6

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

lib/Backend/GlobOptFields.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,12 @@ GlobOpt::UpdateObjPtrValueType(IR::Opnd * opnd, IR::Instr * instr)
19671967
AnalysisAssert(type != nullptr);
19681968
Js::TypeId typeId = type->GetTypeId();
19691969

1970+
if (Js::TypedArrayBase::Is(typeId))
1971+
{
1972+
// Type ID does not allow us to distinguish between virtual and non-virtual typed array.
1973+
return;
1974+
}
1975+
19701976
// Passing false for useVirtual as we would never have a virtual typed array hitting this code path
19711977
ValueType newValueType = ValueType::FromTypeId(typeId, false);
19721978

test/typedarray/definitetypedarray.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
let xxx = new Uint32Array(0x10000);
7+
8+
xxx.slice = Array.prototype.slice;
9+
10+
function jit(arr, index){
11+
let ut = arr.slice(0,0); //become definite Uint32Array but |arr| is a VirtualUint32Array
12+
for(let i = 0; i < 0x30; i++){
13+
arr[i] = 0; //will be crash at |Op_memset|
14+
}
15+
}
16+
17+
for(let i = 0;i < 0x10000; i++){
18+
jit(xxx, 2);
19+
}
20+
21+
if (xxx[0] === 0)
22+
{
23+
WScript.Echo('pass');
24+
}
25+

test/typedarray/rlexe.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,4 +423,9 @@ Below test fails with difference in space. Investigate the cause and re-enable t
423423
<files>bug18321215.js</files>
424424
</default>
425425
</test>
426+
<test>
427+
<default>
428+
<files>definitetypedarray.js</files>
429+
</default>
430+
</test>
426431
</regress-exe>

0 commit comments

Comments
 (0)