@@ -4262,21 +4262,33 @@ void ByteCodeGenerator::EmitLoadInstance(Symbol *sym, IdentPtr pid, Js::RegSlot
42624262 funcInfo->FindOrAddReferencedPropertyId (propertyId),
42634263 envIndex + Js::FrameDisplay::GetOffsetOfScopes () / sizeof (Js::Var));
42644264
4265- Js::RegSlot tmpReg = funcInfo->AcquireTmpRegister ();
4266-
42674265 AssertOrFailFast (scope->GetIsObject ());
4268- this ->m_writer .SlotI1 (Js::OpCode::LdEnvObj, tmpReg,
4269- envIndex + Js::FrameDisplay::GetOffsetOfScopes () / sizeof (Js::Var));
4270-
4271- Js::OpCode op = unwrapWithObj ? Js::OpCode::UnwrapWithObj : Js::OpCode::Ld_A;
42724266
4273- this ->m_writer .Reg2 (op, instLocation, tmpReg);
4274- if (thisLocation != Js::Constants::NoRegister)
4267+ if (unwrapWithObj)
42754268 {
4276- this ->m_writer .Reg2 (op, thisLocation, tmpReg);
4269+ Js::RegSlot tmpReg = funcInfo->AcquireTmpRegister ();
4270+
4271+ this ->m_writer .SlotI1 (Js::OpCode::LdEnvObj, tmpReg,
4272+ envIndex + Js::FrameDisplay::GetOffsetOfScopes () / sizeof (Js::Var));
4273+
4274+ this ->m_writer .Reg2 (Js::OpCode::UnwrapWithObj, instLocation, tmpReg);
4275+ if (thisLocation != Js::Constants::NoRegister)
4276+ {
4277+ this ->m_writer .Reg2 (Js::OpCode::UnwrapWithObj, thisLocation, tmpReg);
4278+ }
4279+
4280+ funcInfo->ReleaseTmpRegister (tmpReg);
42774281 }
4282+ else
4283+ {
4284+ this ->m_writer .SlotI1 (Js::OpCode::LdEnvObj, instLocation,
4285+ envIndex + Js::FrameDisplay::GetOffsetOfScopes () / sizeof (Js::Var));
42784286
4279- funcInfo->ReleaseTmpRegister (tmpReg);
4287+ if (thisLocation != Js::Constants::NoRegister)
4288+ {
4289+ this ->m_writer .Reg2 (Js::OpCode::Ld_A, thisLocation, funcInfo->undefinedConstantRegister );
4290+ }
4291+ }
42804292 }
42814293 else if (scopeLocation != Js::Constants::NoRegister && scopeLocation == funcInfo->frameObjRegister )
42824294 {
@@ -4288,19 +4300,29 @@ void ByteCodeGenerator::EmitLoadInstance(Symbol *sym, IdentPtr pid, Js::RegSlot
42884300 this ->m_writer .Reg1 (Js::OpCode::LdLocalObj, instLocation);
42894301 if (thisLocation != Js::Constants::NoRegister)
42904302 {
4291- this ->m_writer .Reg1 (Js::OpCode::LdLocalObj , thisLocation);
4303+ this ->m_writer .Reg2 (Js::OpCode::Ld_A , thisLocation, funcInfo-> undefinedConstantRegister );
42924304 }
42934305 }
42944306 else
42954307 {
42964308 this ->m_writer .BrProperty (Js::OpCode::BrOnNoProperty, nextLabel, scopeLocation,
42974309 funcInfo->FindOrAddReferencedPropertyId (propertyId));
42984310
4299- Js::OpCode op = unwrapWithObj ? Js::OpCode::UnwrapWithObj : Js::OpCode::Ld_A;
4300- this ->m_writer .Reg2 (op, instLocation, scopeLocation);
4301- if (thisLocation != Js::Constants::NoRegister)
4311+ if (unwrapWithObj)
43024312 {
4303- this ->m_writer .Reg2 (op, thisLocation, scopeLocation);
4313+ this ->m_writer .Reg2 (Js::OpCode::UnwrapWithObj, instLocation, scopeLocation);
4314+ if (thisLocation != Js::Constants::NoRegister)
4315+ {
4316+ this ->m_writer .Reg2 (Js::OpCode::UnwrapWithObj, thisLocation, scopeLocation);
4317+ }
4318+ }
4319+ else
4320+ {
4321+ this ->m_writer .Reg2 (Js::OpCode::Ld_A, instLocation, scopeLocation);
4322+ if (thisLocation != Js::Constants::NoRegister)
4323+ {
4324+ this ->m_writer .Reg2 (Js::OpCode::Ld_A, thisLocation, funcInfo->undefinedConstantRegister );
4325+ }
43044326 }
43054327 }
43064328
0 commit comments