Review fixes
authorGleb Balykov <g.balykov@samsung.com>
Mon, 7 Aug 2017 10:33:58 +0000 (13:33 +0300)
committerGleb Balykov <g.balykov@samsung.com>
Mon, 7 Aug 2017 13:14:08 +0000 (16:14 +0300)
17 files changed:
src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
src/ToolBox/superpmi/superpmi-shared/methodcontext.h
src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
src/inc/corinfo.h
src/jit/ICorJitInfo_API_wrapper.hpp
src/jit/codegenlegacy.cpp
src/jit/emitarm.cpp
src/jit/lower.cpp
src/jit/morph.cpp
src/vm/jitinterface.cpp
src/vm/jitinterface.h
src/zap/zapinfo.cpp
src/zap/zapinfo.h

index 37103bd..ad6b269 100644 (file)
@@ -110,7 +110,7 @@ CORINFO_MODULE_HANDLE getMethodModule(CORINFO_METHOD_HANDLE method);
 void getMethodVTableOffset(CORINFO_METHOD_HANDLE method,                /* IN */
                            unsigned*             offsetOfIndirection,   /* OUT */
                            unsigned*             offsetAfterIndirection,/* OUT */
-                           unsigned*             isRelative             /* OUT */
+                           bool*                 isRelative             /* OUT */
                            );
 
 // Find the virtual method in implementingClass that overrides virtualMethod.
index b13e720..b33e031 100644 (file)
@@ -2972,7 +2972,7 @@ void MethodContext::repGetEHinfo(CORINFO_METHOD_HANDLE ftn, unsigned EHnumber, C
 void MethodContext::recGetMethodVTableOffset(CORINFO_METHOD_HANDLE method,
                                              unsigned*             offsetOfIndirection,
                                              unsigned*             offsetAfterIndirection,
-                                             unsigned*             isRelative)
+                                             bool*                 isRelative)
 {
     if (GetMethodVTableOffset == nullptr)
         GetMethodVTableOffset = new LightWeightMap<DWORDLONG, DDD>();
@@ -2980,18 +2980,18 @@ void MethodContext::recGetMethodVTableOffset(CORINFO_METHOD_HANDLE method,
     DDD value;
     value.A = (DWORD)*offsetOfIndirection;
     value.B = (DWORD)*offsetAfterIndirection;
-    value.C = (DWORD)*isRelative;
+    value.C = *isRelative;
     GetMethodVTableOffset->Add((DWORDLONG)method, value);
     DEBUG_REC(dmpGetMethodVTableOffset((DWORDLONG)method, value));
 }
 void MethodContext::dmpGetMethodVTableOffset(DWORDLONG key, DDD value)
 {
-    printf("GetMethodVTableOffset key ftn-%016llX, value offi-%u, offa-%u", key, value.A, value.B);
+    printf("GetMethodVTableOffset key ftn-%016llX, value offi-%u, offa-%u. offr-%d", key, value.A, value.B, value.C);
 }
 void MethodContext::repGetMethodVTableOffset(CORINFO_METHOD_HANDLE method,
                                              unsigned*             offsetOfIndirection,
                                              unsigned*             offsetAfterIndirection,
-                                             unsigned*             isRelative)
+                                             bool*                 isRelative)
 {
     DDD value;
 
@@ -3003,7 +3003,7 @@ void MethodContext::repGetMethodVTableOffset(CORINFO_METHOD_HANDLE method,
 
     *offsetOfIndirection    = (unsigned)value.A;
     *offsetAfterIndirection = (unsigned)value.B;
-    *isRelative             = (unsigned)value.C;
+    *isRelative             = value.C;
     DEBUG_REP(dmpGetMethodVTableOffset((DWORDLONG)method, value));
 }
 
index 524b0dd..d2f43b4 100644 (file)
@@ -241,7 +241,7 @@ public:
     {
         DWORD A;
         DWORD B;
-        DWORD C;
+        bool C;
     };
     struct Agnostic_CanTailCall
     {
@@ -851,12 +851,12 @@ public:
     void recGetMethodVTableOffset(CORINFO_METHOD_HANDLE method,
                                   unsigned*             offsetOfIndirection,
                                   unsigned*             offsetAfterIndirection,
-                                  unsigned*             isRelative);
+                                  bool*                 isRelative);
     void dmpGetMethodVTableOffset(DWORDLONG key, DDD value);
     void repGetMethodVTableOffset(CORINFO_METHOD_HANDLE method,
                                   unsigned*             offsetOfIndirection,
                                   unsigned*             offsetAfterIndirection,
-                                  unsigned*             isRelative);
+                                  bool*                 isRelative);
 
     void recResolveVirtualMethod(CORINFO_METHOD_HANDLE  virtMethod,
                                  CORINFO_CLASS_HANDLE   implClass,
index 311b57f..d79e4ee 100644 (file)
@@ -215,7 +215,7 @@ CORINFO_MODULE_HANDLE interceptor_ICJI::getMethodModule(CORINFO_METHOD_HANDLE me
 void interceptor_ICJI::getMethodVTableOffset(CORINFO_METHOD_HANDLE method,                /* IN */
                                              unsigned*             offsetOfIndirection,   /* OUT */
                                              unsigned*             offsetAfterIndirection,/* OUT */
-                                             unsigned*             isRelative             /* OUT */
+                                             bool*                 isRelative             /* OUT */
                                              )
 {
     mc->cr->AddCall("getMethodVTableOffset");
index cad7990..d731a77 100644 (file)
@@ -146,7 +146,7 @@ CORINFO_MODULE_HANDLE interceptor_ICJI::getMethodModule(CORINFO_METHOD_HANDLE me
 void interceptor_ICJI::getMethodVTableOffset(CORINFO_METHOD_HANDLE method,                /* IN */
                                              unsigned*             offsetOfIndirection,   /* OUT */
                                              unsigned*             offsetAfterIndirection,/* OUT */
-                                             unsigned*             isRelative             /* OUT */
+                                             bool*                 isRelative             /* OUT */
                                              )
 {
     mcs->AddCall("getMethodVTableOffset");
index 7dc3e7e..fd45a3c 100644 (file)
@@ -135,7 +135,7 @@ CORINFO_MODULE_HANDLE interceptor_ICJI::getMethodModule(CORINFO_METHOD_HANDLE me
 void interceptor_ICJI::getMethodVTableOffset(CORINFO_METHOD_HANDLE method,                /* IN */
                                              unsigned*             offsetOfIndirection,   /* OUT */
                                              unsigned*             offsetAfterIndirection,/* OUT */
-                                             unsigned*             isRelative             /* OUT */
+                                             bool*                 isRelative             /* OUT */
                                              )
 {
     original_ICorJitInfo->getMethodVTableOffset(method, offsetOfIndirection, offsetAfterIndirection, isRelative);
index b282a1f..e8b4187 100644 (file)
@@ -166,7 +166,7 @@ CORINFO_MODULE_HANDLE MyICJI::getMethodModule(CORINFO_METHOD_HANDLE method)
 void MyICJI::getMethodVTableOffset(CORINFO_METHOD_HANDLE method,                /* IN */
                                    unsigned*             offsetOfIndirection,   /* OUT */
                                    unsigned*             offsetAfterIndirection,/* OUT */
-                                   unsigned*             isRelative             /* OUT */
+                                   bool*                 isRelative             /* OUT */
                                    )
 {
     jitInstance->mc->cr->AddCall("getMethodVTableOffset");
index 1638747..084b984 100644 (file)
@@ -2070,7 +2070,7 @@ public:
             CORINFO_METHOD_HANDLE       method,                 /* IN */
             unsigned*                   offsetOfIndirection,    /* OUT */
             unsigned*                   offsetAfterIndirection, /* OUT */
-            unsigned*                   isRelative              /* OUT */
+            bool*                       isRelative              /* OUT */
             ) = 0;
 
     // Find the virtual method in implementingClass that overrides virtualMethod,
index 2c34554..1d30e00 100644 (file)
@@ -123,7 +123,7 @@ void WrapICorJitInfo::getMethodVTableOffset(
             CORINFO_METHOD_HANDLE       method,                 /* IN */
             unsigned*                   offsetOfIndirection,    /* OUT */
             unsigned*                   offsetAfterIndirection, /* OUT */
-            unsigned*                   isRelative              /* OUT */)
+            bool*                       isRelative              /* OUT */)
 {
     API_ENTER(getMethodVTableOffset);
     wrapHnd->getMethodVTableOffset(method, offsetOfIndirection, offsetAfterIndirection, isRelative);
index 65095bd..b612073 100644 (file)
@@ -18853,7 +18853,7 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
                     regMaskTP vptrMask1;
                     unsigned  vtabOffsOfIndirection;
                     unsigned  vtabOffsAfterIndirection;
-                    unsigned  isRelative;
+                    bool      isRelative;
 
                     noway_assert(callType == CT_USER_FUNC);
 
@@ -18907,7 +18907,7 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
                             // ADD vptrReg1, REG_CALL_IND_SCRATCH, vtabOffsOfIndirection + vtabOffsAfterIndirection
                             getEmitter()->emitIns_R_R_I(INS_add, EA_PTRSIZE, vptrReg1, vptrReg, offset);
 #else
-                            _ASSERTE(false);
+                            unreached();
 #endif
                         }
 
@@ -18917,7 +18917,7 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
                     }
                     else
                     {
-                        _ASSERTE(!isRelative);
+                        assert(!isRelative);
                     }
 
                     /* Call through the appropriate vtable slot */
@@ -18931,7 +18931,7 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
                             getEmitter()->emitIns_R_ARR(ins_Load(TYP_I_IMPL), EA_PTRSIZE, REG_TAILCALL_ADDR, vptrReg1,
                                                         vptrReg, 0);
 #else
-                            _ASSERTE(false);
+                            unreached();
 #endif
                         }
                         else
@@ -18961,7 +18961,7 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
                                                    gcInfo.gcRegByrefSetCur, ilOffset,
                                                    vptrReg); // ireg
 #else
-                        _ASSERTE(!isRelative);
+                        assert(!isRelative);
                         getEmitter()->emitIns_Call(emitter::EC_FUNC_VIRTUAL, call->gtCallMethHnd,
                                                    INDEBUG_LDISASM_COMMA(sigInfo) NULL, // addr
                                                    args, retSize, gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur,
index 2928d99..0126b13 100644 (file)
@@ -2459,13 +2459,13 @@ void emitter::emitIns_R_R_I(instruction ins,
                 fmt = IF_T2_M0;
                 sf  = INS_FLAGS_NOT_SET;
             }
-            else if (insDoesNotSetFlags(flags) && reg1 != REG_SP && reg1 != REG_PC)
+            else if (insDoesNotSetFlags(flags) && (reg1 != REG_SP) && (reg1 != REG_PC))
             {
                 // movw,movt reg1, imm
-                codeGen->instGen_Set_Reg_To_Imm(attr, reg1, imm);
+                codeGen->instGen_Set_Reg_To_Imm(attr, reg1, (ins == INS_sub ? -1 : 1) * imm);
 
                 // ins reg1, reg2
-                emitIns_R_R(ins, attr, reg1, reg2);
+                emitIns_R_R(INS_add, attr, reg1, reg2);
 
                 return;
             }
index 0752872..4c1b543 100644 (file)
@@ -3461,7 +3461,7 @@ GenTree* Lowering::LowerVirtualVtableCall(GenTreeCall* call)
     // Get hold of the vtable offset (note: this might be expensive)
     unsigned vtabOffsOfIndirection;
     unsigned vtabOffsAfterIndirection;
-    unsigned isRelative;
+    bool     isRelative;
     comp->info.compCompHnd->getMethodVTableOffset(call->gtCallMethHnd, &vtabOffsOfIndirection,
                                                   &vtabOffsAfterIndirection, &isRelative);
 
@@ -3485,13 +3485,24 @@ GenTree* Lowering::LowerVirtualVtableCall(GenTreeCall* call)
     {
         if (isRelative)
         {
+            // MethodTable offset is a relative pointer.
+            //
+            // Additional temporary variable is used to store virtual table pointer.
+            // Address of method is obtained by the next computations:
+            //
+            // Save relative offset to tmp (vtab is virtual table pointer, vtabOffsOfIndirection is offset of
+            // vtable-1st-level-indirection):
+            // tmp = [vtab + vtabOffsOfIndirection]
+            //
+            // Save address of method to result (vtabOffsAfterIndirection is offset of vtable-2nd-level-indirection):
+            // result = [vtab + vtabOffsOfIndirection + vtabOffsAfterIndirection + tmp]
             unsigned lclNumTmp = comp->lvaGrabTemp(true DEBUGARG("lclNumTmp"));
 
             comp->lvaTable[lclNumTmp].incRefCnts(comp->compCurBB->getBBWeight(comp), comp);
             GenTree* lclvNodeStore = comp->gtNewTempAssign(lclNumTmp, result);
 
             LIR::Range range = LIR::SeqTree(comp, lclvNodeStore);
-            JITDUMP("results of lowering call interm:\n");
+            JITDUMP("result of obtaining pointer to virtual table:\n");
             DISPRANGE(range);
             BlockRange().InsertBefore(call, std::move(range));
 
@@ -3512,7 +3523,7 @@ GenTree* Lowering::LowerVirtualVtableCall(GenTreeCall* call)
     }
     else
     {
-        _ASSERTE(!isRelative);
+        assert(!isRelative);
     }
 
     // Load the function address
index 40b609a..178003a 100644 (file)
@@ -7170,7 +7170,7 @@ void Compiler::fgMorphTailCall(GenTreeCall* call)
 
         unsigned vtabOffsOfIndirection;
         unsigned vtabOffsAfterIndirection;
-        unsigned isRelative;
+        bool     isRelative;
         info.compCompHnd->getMethodVTableOffset(call->gtCallMethHnd, &vtabOffsOfIndirection, &vtabOffsAfterIndirection,
                                                 &isRelative);
 
index 11b1b18..4d8e607 100644 (file)
@@ -8587,7 +8587,7 @@ CONTRACTL {
 void CEEInfo::getMethodVTableOffset (CORINFO_METHOD_HANDLE methodHnd,
                                      unsigned * pOffsetOfIndirection,
                                      unsigned * pOffsetAfterIndirection,
-                                     unsigned * isRelative)
+                                     bool * isRelative)
 {
     CONTRACTL {
         SO_TOLERANT;
index cbb24e0..0e9075b 100644 (file)
@@ -728,7 +728,7 @@ public:
             CORINFO_METHOD_HANDLE methodHnd,
             unsigned * pOffsetOfIndirection,
             unsigned * pOffsetAfterIndirection,
-            unsigned * isRelative);
+            bool * isRelative);
 
     CORINFO_METHOD_HANDLE resolveVirtualMethod(
         CORINFO_METHOD_HANDLE virtualMethod,
index 2f38523..f8305dc 100644 (file)
@@ -3704,7 +3704,7 @@ CORINFO_MODULE_HANDLE ZapInfo::getMethodModule(CORINFO_METHOD_HANDLE method)
 void ZapInfo::getMethodVTableOffset(CORINFO_METHOD_HANDLE method,
                                     unsigned * pOffsetOfIndirection,
                                     unsigned * pOffsetAfterIndirection,
-                                    unsigned * isRelative)
+                                    bool * isRelative)
 {
     m_pEEJitInfo->getMethodVTableOffset(method, pOffsetOfIndirection, pOffsetAfterIndirection, isRelative);
 }
index 24ca895..88f095b 100644 (file)
@@ -663,7 +663,7 @@ public:
     void getMethodVTableOffset(CORINFO_METHOD_HANDLE method,
                                unsigned * pOffsetOfIndirection,
                                unsigned * pOffsetAfterIndirection,
-                               unsigned * isRelative);
+                               bool * isRelative);
 
     CORINFO_METHOD_HANDLE resolveVirtualMethod(
         CORINFO_METHOD_HANDLE virtualMethod,