Skip to content

Commit 8ee6c4c

Browse files
committed
[MERGE #6151 @pleath] OSG:21622839 Do not assign slot indices to objtypespec field info during the prepass
Merge pull request #6151 from pleath:21622839 Object pointer copy prop + depolymorphication may cause these indices to change between passes.
2 parents 580a56f + 677a91f commit 8ee6c4c

File tree

3 files changed

+46
-10
lines changed

3 files changed

+46
-10
lines changed

lib/Backend/GlobOptFields.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,12 +1326,6 @@ GlobOpt::ProcessPropOpInTypeCheckSeq(IR::Instr* instr, IR::PropertySymOpnd *opnd
13261326
{
13271327
// Indicates we can optimize, as all upstream types are equivalent here.
13281328

1329-
opnd->SetSlotIndex(slotIndex);
1330-
opnd->SetUsesAuxSlot(auxSlot);
1331-
1332-
opnd->GetObjTypeSpecInfo()->SetSlotIndex(slotIndex);
1333-
opnd->GetObjTypeSpecInfo()->SetUsesAuxSlot(auxSlot);
1334-
13351329
isSpecialized = true;
13361330
if (isTypeCheckedOut)
13371331
{
@@ -1340,10 +1334,17 @@ GlobOpt::ProcessPropOpInTypeCheckSeq(IR::Instr* instr, IR::PropertySymOpnd *opnd
13401334
if (consumeType)
13411335
{
13421336
opnd->SetTypeChecked(true);
1343-
}
1344-
if (checkedTypeSetIndex != (uint16)-1)
1345-
{
1346-
opnd->SetCheckedTypeSetIndex(checkedTypeSetIndex);
1337+
1338+
opnd->SetSlotIndex(slotIndex);
1339+
opnd->SetUsesAuxSlot(auxSlot);
1340+
1341+
opnd->GetObjTypeSpecInfo()->SetSlotIndex(slotIndex);
1342+
opnd->GetObjTypeSpecInfo()->SetUsesAuxSlot(auxSlot);
1343+
1344+
if (checkedTypeSetIndex != (uint16)-1)
1345+
{
1346+
opnd->SetCheckedTypeSetIndex(checkedTypeSetIndex);
1347+
}
13471348
}
13481349
}
13491350
}

test/fieldopts/depolymorph01.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
function test0() {
7+
var obj0 = {};
8+
var arrObj0 = {};
9+
var litObj0 = { prop1: 3.14159265358979 };
10+
var func1 = function (argMath1 = func0(), argMath3) {
11+
protoObj0.prop0 = ++this.prop0;
12+
this.prop0 = argMath3;
13+
};
14+
obj0.method0 = func1;
15+
obj0.method1 = obj0.method0;
16+
var IntArr0 = Array();
17+
var protoObj0 = Object.create(obj0);
18+
prop0 = 1;
19+
protoObj0.method0.call(litObj0, arrObj0);
20+
while (prop0) {
21+
protoObj0.method1(arrObj0);
22+
obj0.method0(obj0);
23+
prop0 = IntArr0.shift();
24+
}
25+
obj0.method0('');
26+
}
27+
test0();
28+
test0();
29+
test0();
30+
WScript.Echo('pass');

test/fieldopts/rlexe.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<regress-exe>
3+
<test>
4+
<default>
5+
<files>depolymorph01.js</files>
6+
</default>
7+
</test>
38
<test>
49
<default>
510
<files>equiv-finaltypeandpoly.js</files>

0 commit comments

Comments
 (0)