@@ -1028,15 +1028,16 @@ IR::Instr *
1028
1028
LowererMD::LowerEntryInstr (IR::EntryInstr * entryInstr)
1029
1029
{
1030
1030
1031
- // IR::Instr *insertInstr = entryInstr->m_next;
1031
+ IR::Instr *insertInstr = entryInstr->m_next ;
1032
1032
1033
1033
// ARM64_WORKITEM
1034
- __debugbreak ();
1034
+ // __debugbreak();
1035
1035
1036
- #if 0
1036
+ // #if 0
1037
1037
1038
1038
BYTE regEncode;
1039
1039
BOOL hasTry = this ->m_func ->HasTry ();
1040
+ AssertMsg (!hasTry, " ToDo (SaAgarwa): prolog not implemented for try" );
1040
1041
1041
1042
// Begin recording info for later pdata/xdata emission.
1042
1043
UnwindInfoManager *unwindInfo = &this ->m_func ->m_unwindInfo ;
@@ -1158,7 +1159,7 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1158
1159
}
1159
1160
}
1160
1161
1161
- BVUnit32 usedDoubleRegs;
1162
+ BVUnit usedDoubleRegs;
1162
1163
short doubleRegCount = 0 ;
1163
1164
1164
1165
if (!hasTry)
@@ -1176,8 +1177,11 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1176
1177
1177
1178
if (doubleRegCount)
1178
1179
{
1180
+ #pragma warning(push)
1181
+ #pragma warning(disable:4244) // warning C4244: 'argument': conversion from 'UnitWord64' to 'DWORD', possible loss of data
1179
1182
BYTE lastDoubleReg = UnwindInfoManager::GetLastSavedReg (usedDoubleRegs.GetWord ());
1180
1183
BYTE firstDoubleReg = UnwindInfoManager::GetFirstSavedReg (usedDoubleRegs.GetWord ());
1184
+ #pragma warning(pop)
1181
1185
1182
1186
// We do want to push all the double registers in a single VPUSH instructions
1183
1187
// This might cause us to VPUSH some registers which are not used
@@ -1202,7 +1206,10 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1202
1206
1203
1207
if (doubleRegCount)
1204
1208
{
1209
+ #pragma warning(push)
1210
+ #pragma warning(disable:4244) // warning C4244: 'argument': conversion from 'UnitWord64' to 'DWORD', possible loss of data
1205
1211
unwindInfo->SetDoubleSavedRegList (usedDoubleRegs.GetWord ());
1212
+ #pragma warning(pop)
1206
1213
fpOffsetSize += (doubleRegCount * MachRegDouble);
1207
1214
1208
1215
// When there is try-catch we allocate registers even if there are no calls. For scenarios see Win8 487030.
@@ -1260,9 +1267,9 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1260
1267
}
1261
1268
}
1262
1269
1263
- bool useDynamicStackProbe =
1270
+ bool useDynamicStackProbe = false ; /*
1264
1271
(m_func->GetJITFunctionBody()->DoInterruptProbe() || !m_func->GetThreadContextInfo()->IsThreadBound()) &&
1265
- !EncoderMD::CanEncodeModConst12(stackProbeStackHeight + Js::Constants::MinStackJIT);
1272
+ !EncoderMD::CanEncodeModConst12(stackProbeStackHeight + Js::Constants::MinStackJIT);*/
1266
1273
1267
1274
if (useDynamicStackProbe && !hasCalls)
1268
1275
{
@@ -1344,16 +1351,26 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1344
1351
GenerateStackProbe (insertInstr, false ); // stack is already aligned in this case
1345
1352
}
1346
1353
1347
- IR::RegOpnd * r12Opnd = nullptr;
1354
+ IR::RegOpnd * r17Opnd = nullptr ;
1355
+
1356
+ /*
1357
+ Homed arguments (r0-r7)
1358
+ Callee-Saved float Registers (d16-d29)
1359
+ Callee-Saved Int Registers (r19-r28)
1360
+ Local Variables
1361
+ lr - link Register (r30)
1362
+ fp - Frame Pointer (r29)
1363
+ alloca area
1364
+ */
1348
1365
1349
1366
// Zero-initialize dedicated arguments slot
1350
1367
if (hasCalls)
1351
1368
{
1352
- //R12 acts a dummy zero register which we push to arguments slot
1353
- //mov r12 , 0
1354
- Assert(r12Opnd == nullptr);
1355
- r12Opnd = IR::RegOpnd::New(nullptr, SCRATCH_REG, TyMachReg, this->m_func);
1356
- IR::Instr * instrMov = IR::Instr::New(Js::OpCode::MOV, r12Opnd , IR::IntConstOpnd::New(0, TyMachReg, this->m_func), this->m_func);
1369
+ // R17 acts a dummy zero register which we push to arguments slot
1370
+ // mov r17 , 0
1371
+ Assert (r17Opnd == nullptr );
1372
+ r17Opnd = IR::RegOpnd::New (nullptr , SCRATCH_REG, TyMachReg, this ->m_func );
1373
+ IR::Instr * instrMov = IR::Instr::New (Js::OpCode::MOV, r17Opnd , IR::IntConstOpnd::New (0 , TyMachReg, this ->m_func ), this ->m_func );
1357
1374
insertInstr->InsertBefore (instrMov);
1358
1375
IR::LabelInstr *prologStartLabel = IR::LabelInstr::New (Js::OpCode::Label, this ->m_func );
1359
1376
insertInstr->InsertBefore (prologStartLabel);
@@ -1362,37 +1379,51 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1362
1379
1363
1380
if (!paramRegs.IsEmpty ())
1364
1381
{
1382
+ for (int i = LAST_INT_ARG_REG; i >= FIRST_INT_ARG_REG; --i)
1383
+ {
1384
+ RegNum reg = (RegNum)(i);
1385
+ if (paramRegs.Test (RegEncode[reg]))
1386
+ {
1387
+ IR::Instr * instrStore = IR::Instr::New (Js::OpCode::STR, this ->m_func );
1388
+ instrStore->SetDst (IR::IndirOpnd::New (IR::RegOpnd::New (nullptr , RegSP, TyMachReg, this ->m_func ), (int32)0 , TyMachReg, this ->m_func ));
1389
+ instrStore->SetSrc1 (IR::RegOpnd::New (reg, TyMachReg, this ->m_func ));
1390
+ insertInstr->InsertBefore (instrStore);
1391
+ }
1392
+ }
1393
+
1394
+ /*
1365
1395
// Generate PUSH {r0-r3}
1366
- IR::Instr * instrPush = IR::Instr::New(Js::OpCode::PUSH , this->m_func);
1396
+ IR::Instr * instrPush = IR::Instr::New(Js::OpCode::STP , this->m_func);
1367
1397
instrPush->SetDst(IR::IndirOpnd::New(IR::RegOpnd::New(nullptr, RegSP, TyMachReg, this->m_func), (int32)0, TyMachReg, this->m_func));
1368
1398
instrPush->SetSrc1(IR::RegBVOpnd::New(paramRegs, TyMachReg, this->m_func));
1369
1399
insertInstr->InsertBefore(instrPush);
1400
+ */
1370
1401
}
1371
1402
1372
1403
// Setup Frame pointer
1373
1404
if (hasCalls)
1374
1405
{
1375
1406
BVUnit frameRegs;
1376
- frameRegs.Set(RegEncode[RegR11 ]);
1407
+ frameRegs.Set (RegEncode[RegFP ]);
1377
1408
frameRegs.Set (RegEncode[RegLR]);
1378
1409
1379
1410
// Generate PUSH {r11,lr}
1380
- IR::Instr * instrPush = IR::Instr::New(Js::OpCode::PUSH , this->m_func);
1411
+ IR::Instr * instrPush = IR::Instr::New (Js::OpCode::STP , this ->m_func );
1381
1412
instrPush->SetDst (IR::IndirOpnd::New (IR::RegOpnd::New (nullptr , RegSP, TyMachReg, this ->m_func ), (int32)0 , TyMachReg, this ->m_func ));
1382
1413
instrPush->SetSrc1 (IR::RegBVOpnd::New (frameRegs, TyMachReg, this ->m_func ));
1383
1414
insertInstr->InsertBefore (instrPush);
1384
1415
1385
- // Generate MOV r11 ,sp
1416
+ // Generate MOV fp ,sp
1386
1417
IR::RegOpnd* spOpnd = IR::RegOpnd::New (nullptr , RegSP, TyMachReg, this ->m_func );
1387
- IR::RegOpnd* r11Opnd = IR::RegOpnd::New(nullptr, RegR11 , TyMachReg, this->m_func);
1418
+ IR::RegOpnd* r11Opnd = IR::RegOpnd::New (nullptr , RegFP , TyMachReg, this ->m_func );
1388
1419
IR::Instr * instrMov = IR::Instr::New (Js::OpCode::MOV, r11Opnd, spOpnd, this ->m_func );
1389
1420
insertInstr->InsertBefore (instrMov);
1390
1421
}
1391
1422
1392
1423
if (!usedRegs.IsEmpty ())
1393
1424
{
1394
1425
// Generate PUSH {r4-r10,r12}
1395
- IR::Instr * instrPush = IR::Instr::New(Js::OpCode::PUSH , this->m_func);
1426
+ IR::Instr * instrPush = IR::Instr::New (Js::OpCode::STP , this ->m_func );
1396
1427
instrPush->SetDst (IR::IndirOpnd::New (IR::RegOpnd::New (nullptr , RegSP, TyMachReg, this ->m_func ), (int32)0 , TyMachReg, this ->m_func ));
1397
1428
instrPush->SetSrc1 (IR::RegBVOpnd::New (usedRegs, TyMachReg, this ->m_func ));
1398
1429
insertInstr->InsertBefore (instrPush);
@@ -1401,7 +1432,7 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1401
1432
if (!usedDoubleRegs.IsEmpty ())
1402
1433
{
1403
1434
// Generate VPUSH {d8-d15}
1404
- IR::Instr * instrPush = IR::Instr::New(Js::OpCode::VPUSH , this->m_func);
1435
+ IR::Instr * instrPush = IR::Instr::New (Js::OpCode::STP64 , this ->m_func );
1405
1436
instrPush->SetDst (IR::IndirOpnd::New (IR::RegOpnd::New (nullptr , RegSP, TyMachReg, this ->m_func ), (int32)0 , TyMachReg, this ->m_func ));
1406
1437
instrPush->SetSrc1 (IR::RegBVOpnd::New (usedDoubleRegs, TyMachReg, this ->m_func ));
1407
1438
insertInstr->InsertBefore (instrPush);
@@ -1451,7 +1482,7 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1451
1482
ehReg.Set (RegEncode[EH_STACK_SAVE_REG]);
1452
1483
IR::Instr * instrPush =
1453
1484
IR::Instr::New (
1454
- Js::OpCode::PUSH ,
1485
+ Js::OpCode::STP ,
1455
1486
IR::IndirOpnd::New (
1456
1487
IR::RegOpnd::New (nullptr , RegSP, TyMachReg, this ->m_func ), (int32)0 , TyMachReg, this ->m_func ),
1457
1488
IR::RegBVOpnd::New (ehReg, TyMachReg, this ->m_func ),
@@ -1472,11 +1503,11 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1472
1503
if (m_func->GetMaxInlineeArgOutSize () != 0 )
1473
1504
{
1474
1505
// This is done post prolog. so we don't have to emit unwind data.
1475
- if (r12Opnd == nullptr || isScratchRegisterThrashed)
1506
+ if (r17Opnd == nullptr || isScratchRegisterThrashed)
1476
1507
{
1477
- r12Opnd = r12Opnd ? r12Opnd : IR::RegOpnd::New(nullptr, SCRATCH_REG, TyMachReg, this->m_func);
1508
+ r17Opnd = r17Opnd ? r17Opnd : IR::RegOpnd::New (nullptr , SCRATCH_REG, TyMachReg, this ->m_func );
1478
1509
// mov r12, 0
1479
- IR::Instr * instrMov = IR::Instr::New(Js::OpCode::MOV, r12Opnd , IR::IntConstOpnd::New(0, TyMachReg, this->m_func), this->m_func);
1510
+ IR::Instr * instrMov = IR::Instr::New (Js::OpCode::MOV, r17Opnd , IR::IntConstOpnd::New (0 , TyMachReg, this ->m_func ), this ->m_func );
1480
1511
insertInstr->InsertBefore (instrMov);
1481
1512
}
1482
1513
@@ -1487,7 +1518,7 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1487
1518
IR::Opnd *dst = IR::SymOpnd::New (sym, 0 , TyMachReg, this ->m_func );
1488
1519
insertInstr->InsertBefore (IR::Instr::New (Js::OpCode::STR,
1489
1520
dst,
1490
- r12Opnd ,
1521
+ r17Opnd ,
1491
1522
this ->m_func ));
1492
1523
}
1493
1524
@@ -1497,7 +1528,7 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
1497
1528
{
1498
1529
GenerateStackProbe (insertInstr, true ); // stack is already aligned in this case
1499
1530
}
1500
- #endif
1531
+ // #endif
1501
1532
1502
1533
return entryInstr;
1503
1534
}
@@ -1506,7 +1537,7 @@ IR::Instr *
1506
1537
LowererMD::LowerExitInstr (IR::ExitInstr * exitInstr)
1507
1538
{
1508
1539
// ARM64_WORKITEM
1509
- __debugbreak ();
1540
+ // __debugbreak();
1510
1541
1511
1542
#if 0
1512
1543
@@ -1549,7 +1580,7 @@ LowererMD::LowerExitInstr(IR::ExitInstr * exitInstr)
1549
1580
1550
1581
// Record used callee-saved registers. This is in the form of a fixed bitfield.
1551
1582
1552
- BVUnit32 usedRegs;
1583
+ BVUnit usedRegs;
1553
1584
for (RegNum reg = FIRST_CALLEE_SAVED_GP_REG; reg <= LAST_CALLEE_SAVED_GP_REG; reg = (RegNum)(reg+1))
1554
1585
{
1555
1586
Assert(LinearScan::IsCalleeSaved(reg));
@@ -1616,7 +1647,7 @@ LowererMD::LowerExitInstr(IR::ExitInstr * exitInstr)
1616
1647
}
1617
1648
1618
1649
// 2. Restore saved double registers. Generate vpop {d8-d15}
1619
- BVUnit32 savedDoubleRegs(this->m_func->m_unwindInfo.GetDoubleSavedRegList());
1650
+ BVUnit savedDoubleRegs(this->m_func->m_unwindInfo.GetDoubleSavedRegList());
1620
1651
if (!savedDoubleRegs.IsEmpty())
1621
1652
{
1622
1653
IR::Instr * instrVPop = IR::Instr::New(Js::OpCode::VPOP, this->m_func);
0 commit comments