@@ -24326,113 +24326,122 @@ Lowerer::TryGenerateFastBrOrCmTypeOf(IR::Instr *instr, IR::Instr **prev, bool is
24326
24326
24327
24327
if (typeOfDst && instrSrc1 && instrSrc2)
24328
24328
{
24329
- IR::RegOpnd *typeOpnd = nullptr;
24330
- IR::RegOpnd *idOpnd = nullptr;
24331
- if (instrSrc1->m_sym == typeOfDst->m_sym)
24329
+ do
24332
24330
{
24333
- typeOpnd = instrSrc1;
24334
- idOpnd = instrSrc2;
24335
- }
24336
- else if (instrSrc2->m_sym == typeOfDst->m_sym)
24337
- {
24338
- typeOpnd = instrSrc2;
24339
- idOpnd = instrSrc1;
24340
- }
24341
- else
24342
- {
24343
- // Neither source turned out to be the typeOpnd
24344
- return false;
24345
- }
24331
+ IR::RegOpnd *typeOpnd = nullptr;
24332
+ IR::RegOpnd *idOpnd = nullptr;
24333
+ if (instrSrc1->m_sym == typeOfDst->m_sym)
24334
+ {
24335
+ typeOpnd = instrSrc1;
24336
+ idOpnd = instrSrc2;
24337
+ }
24338
+ else if (instrSrc2->m_sym == typeOfDst->m_sym)
24339
+ {
24340
+ typeOpnd = instrSrc2;
24341
+ idOpnd = instrSrc1;
24342
+ }
24343
+ else
24344
+ {
24345
+ // Neither source turned out to be the typeOpnd
24346
+ break;
24347
+ }
24346
24348
24347
- if (!typeOpnd->m_isTempLastUse)
24348
- {
24349
- return false ;
24350
- }
24349
+ if (!typeOpnd->m_isTempLastUse)
24350
+ {
24351
+ break ;
24352
+ }
24351
24353
24352
- if (!(idOpnd->m_sym->m_isSingleDef && idOpnd->m_sym->m_isStrConst))
24353
- {
24354
- return false;
24355
- }
24354
+ if (!(idOpnd->m_sym->m_isSingleDef && idOpnd->m_sym->m_isStrConst))
24355
+ {
24356
+ return false;
24357
+ }
24356
24358
24357
- // The second argument to [Cm|Br]TypeOf is the typeid.
24358
- IR::IntConstOpnd *typeIdOpnd = nullptr;
24359
+ // The second argument to [Cm|Br]TypeOf is the typeid.
24360
+ IR::IntConstOpnd *typeIdOpnd = nullptr;
24359
24361
24360
- Assert(idOpnd->m_sym->m_isSingleDef);
24361
- Assert(idOpnd->m_sym->m_instrDef->GetSrc1()->IsAddrOpnd());
24362
+ Assert(idOpnd->m_sym->m_isSingleDef);
24363
+ Assert(idOpnd->m_sym->m_instrDef->GetSrc1()->IsAddrOpnd());
24362
24364
24363
- // We can't optimize non-javascript type strings.
24364
- JITJavascriptString *typeNameJsString = JITJavascriptString::FromVar(idOpnd->m_sym->m_instrDef->GetSrc1()->AsAddrOpnd()->m_localAddress);
24365
- const char16 *typeName = typeNameJsString->GetString();
24365
+ // We can't optimize non-javascript type strings.
24366
+ JITJavascriptString *typeNameJsString = JITJavascriptString::FromVar(idOpnd->m_sym->m_instrDef->GetSrc1()->AsAddrOpnd()->m_localAddress);
24367
+ const char16 *typeName = typeNameJsString->GetString();
24366
24368
24367
- Js::InternalString typeNameString(typeName, typeNameJsString->GetLength());
24368
- if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::UndefinedTypeNameString))
24369
- {
24370
- typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Undefined, TyInt32, instr->m_func);
24371
- }
24372
- else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::ObjectTypeNameString))
24373
- {
24374
- typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Object, TyInt32, instr->m_func);
24375
- }
24376
- else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::BooleanTypeNameString))
24377
- {
24378
- typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Boolean, TyInt32, instr->m_func);
24379
- }
24380
- else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::NumberTypeNameString))
24381
- {
24382
- typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Number, TyInt32, instr->m_func);
24383
- }
24384
- else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::StringTypeNameString))
24385
- {
24386
- typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_String, TyInt32, instr->m_func);
24387
- }
24388
- else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::FunctionTypeNameString))
24389
- {
24390
- typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Function, TyInt32, instr->m_func);
24391
- }
24392
- else
24393
- {
24394
- return false;
24395
- }
24369
+ Js::InternalString typeNameString(typeName, typeNameJsString->GetLength());
24370
+ if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::UndefinedTypeNameString))
24371
+ {
24372
+ typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Undefined, TyInt32, instr->m_func);
24373
+ }
24374
+ else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::ObjectTypeNameString))
24375
+ {
24376
+ typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Object, TyInt32, instr->m_func);
24377
+ }
24378
+ else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::BooleanTypeNameString))
24379
+ {
24380
+ typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Boolean, TyInt32, instr->m_func);
24381
+ }
24382
+ else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::NumberTypeNameString))
24383
+ {
24384
+ typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Number, TyInt32, instr->m_func);
24385
+ }
24386
+ else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::StringTypeNameString))
24387
+ {
24388
+ typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_String, TyInt32, instr->m_func);
24389
+ }
24390
+ else if (Js::InternalStringComparer::Equals(typeNameString, Js::Type::FunctionTypeNameString))
24391
+ {
24392
+ typeIdOpnd = IR::IntConstOpnd::New(Js::TypeIds_Function, TyInt32, instr->m_func);
24393
+ }
24394
+ else
24395
+ {
24396
+ return false;
24397
+ }
24396
24398
24397
- if (skippedLoads)
24398
- {
24399
- //validate none of dst of Ld_A overlaps with typeof src or dst
24400
- IR::Opnd* typeOfSrc = typeOf->GetSrc1();
24401
- instrLd = typeOf->GetNextRealInstr();
24402
- while (instrLd != instr)
24399
+ if (skippedLoads)
24403
24400
{
24404
- if (instrLd->GetDst()->IsEqual(typeOfDst) || instrLd->GetDst()->IsEqual(typeOfSrc))
24401
+ //validate none of dst of Ld_A overlaps with typeof src or dst
24402
+ IR::Opnd* typeOfSrc = typeOf->GetSrc1();
24403
+ instrLd = typeOf->GetNextRealInstr();
24404
+ while (instrLd != instr)
24405
24405
{
24406
- return false;
24406
+ if (instrLd->GetDst()->IsEqual(typeOfDst) || instrLd->GetDst()->IsEqual(typeOfSrc))
24407
+ {
24408
+ return false;
24409
+ }
24410
+ instrLd = instrLd->GetNextRealInstr();
24407
24411
}
24408
- instrLd = instrLd->GetNextRealInstr();
24412
+ typeOf->Unlink();
24413
+ instr->InsertBefore(typeOf);
24414
+ }
24415
+ // The first argument to [Cm|Br]TypeOf is the first arg to the TypeOf instruction.
24416
+ IR::Opnd *objectOpnd = typeOf->GetSrc1();
24417
+ Assert(objectOpnd->IsRegOpnd());
24418
+
24419
+ // Now emit this instruction and remove the ldstr and typeOf.
24420
+ *prev = typeOf->m_prev;
24421
+ *pfNoLower = false;
24422
+ if (instr->IsBranchInstr())
24423
+ {
24424
+ GenerateFastBrTypeOf(instr, objectOpnd->AsRegOpnd(), typeIdOpnd, typeOf, pfNoLower, isNeqOp);
24425
+ }
24426
+ else
24427
+ {
24428
+ GenerateFastCmTypeOf(instr, objectOpnd->AsRegOpnd(), typeIdOpnd, typeOf, pfNoLower, isNeqOp);
24409
24429
}
24410
- typeOf->Unlink();
24411
- instr->InsertBefore(typeOf);
24412
- }
24413
- // The first argument to [Cm|Br]TypeOf is the first arg to the TypeOf instruction.
24414
- IR::Opnd *objectOpnd = typeOf->GetSrc1();
24415
- Assert(objectOpnd->IsRegOpnd());
24416
-
24417
- // Now emit this instruction and remove the ldstr and typeOf.
24418
- *prev = typeOf->m_prev;
24419
- *pfNoLower = false;
24420
- if (instr->IsBranchInstr())
24421
- {
24422
- GenerateFastBrTypeOf(instr, objectOpnd->AsRegOpnd(), typeIdOpnd, typeOf, pfNoLower, isNeqOp);
24423
- }
24424
- else
24425
- {
24426
- GenerateFastCmTypeOf(instr, objectOpnd->AsRegOpnd(), typeIdOpnd, typeOf, pfNoLower, isNeqOp);
24427
- }
24428
24430
24429
- return true;
24431
+ return true;
24432
+ } while (false);
24430
24433
}
24431
24434
}
24432
24435
24433
24436
if (instrSrc1 && instrSrc1->GetStackSym()->IsSingleDef() && instrSrc2 && instrSrc2->GetStackSym()->IsSingleDef() &&
24434
- instrSrc1->GetStackSym()->GetInstrDef()->m_opcode == Js::OpCode::Typeof &&
24435
- instrSrc2->GetStackSym()->GetInstrDef()->m_opcode == Js::OpCode::Typeof)
24437
+ (
24438
+ ((instrSrc1->GetStackSym()->GetInstrDef()->m_opcode == Js::OpCode::Typeof) &&
24439
+ ((instrSrc2->GetStackSym()->GetInstrDef()->m_opcode == Js::OpCode::Typeof) || instrSrc2->GetStackSym()->GetIsStrConst()))
24440
+ ||
24441
+ ((instrSrc2->GetStackSym()->GetInstrDef()->m_opcode == Js::OpCode::Typeof) &&
24442
+ ((instrSrc1->GetStackSym()->GetInstrDef()->m_opcode == Js::OpCode::Typeof) || instrSrc1->GetStackSym()->GetIsStrConst()))
24443
+ )
24444
+ )
24436
24445
{
24437
24446
*pfNoLower = true;
24438
24447
if (instr->IsBranchInstr())
0 commit comments