diff options
author | Gleb Balykov <g.balykov@samsung.com> | 2017-08-07 13:33:58 +0300 |
---|---|---|
committer | Gleb Balykov <g.balykov@samsung.com> | 2017-08-07 16:14:08 +0300 |
commit | 76a572a65026f277c5c42b25fcb01cce4625b10f (patch) | |
tree | 0298b9efc0decbb755619d30a10556fe2233b49c | |
parent | be7d375af43261c4ff8f84aad9ea27ecce145fc6 (diff) | |
download | coreclr-76a572a65026f277c5c42b25fcb01cce4625b10f.tar.gz coreclr-76a572a65026f277c5c42b25fcb01cce4625b10f.tar.bz2 coreclr-76a572a65026f277c5c42b25fcb01cce4625b10f.zip |
Review fixes
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h | 2 | ||||
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp | 10 | ||||
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shared/methodcontext.h | 6 | ||||
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp | 2 | ||||
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp | 2 | ||||
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp | 2 | ||||
-rw-r--r-- | src/ToolBox/superpmi/superpmi/icorjitinfo.cpp | 2 | ||||
-rw-r--r-- | src/inc/corinfo.h | 2 | ||||
-rw-r--r-- | src/jit/ICorJitInfo_API_wrapper.hpp | 2 | ||||
-rw-r--r-- | src/jit/codegenlegacy.cpp | 10 | ||||
-rw-r--r-- | src/jit/emitarm.cpp | 6 | ||||
-rw-r--r-- | src/jit/lower.cpp | 17 | ||||
-rw-r--r-- | src/jit/morph.cpp | 2 | ||||
-rw-r--r-- | src/vm/jitinterface.cpp | 2 | ||||
-rw-r--r-- | src/vm/jitinterface.h | 2 | ||||
-rw-r--r-- | src/zap/zapinfo.cpp | 2 | ||||
-rw-r--r-- | src/zap/zapinfo.h | 2 |
17 files changed, 42 insertions, 31 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h index 37103bd912..ad6b269041 100644 --- a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h +++ b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h @@ -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. diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp index b13e720ded..b33e0318b5 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp @@ -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)); } diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h index 524b0dde70..d2f43b477a 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h @@ -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, diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 311b57ffc5..d79e4ee51a 100644 --- a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -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"); diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp index cad7990c44..d731a773f0 100644 --- a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -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"); diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp index 7dc3e7e0d9..fd45a3c2dc 100644 --- a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -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); diff --git a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp index b282a1f910..e8b4187a99 100644 --- a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp @@ -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"); diff --git a/src/inc/corinfo.h b/src/inc/corinfo.h index 163874788b..084b9841bb 100644 --- a/src/inc/corinfo.h +++ b/src/inc/corinfo.h @@ -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, diff --git a/src/jit/ICorJitInfo_API_wrapper.hpp b/src/jit/ICorJitInfo_API_wrapper.hpp index 2c345540cf..1d30e0096e 100644 --- a/src/jit/ICorJitInfo_API_wrapper.hpp +++ b/src/jit/ICorJitInfo_API_wrapper.hpp @@ -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); diff --git a/src/jit/codegenlegacy.cpp b/src/jit/codegenlegacy.cpp index 65095bd5f1..b612073514 100644 --- a/src/jit/codegenlegacy.cpp +++ b/src/jit/codegenlegacy.cpp @@ -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, diff --git a/src/jit/emitarm.cpp b/src/jit/emitarm.cpp index 2928d9957e..0126b13b1e 100644 --- a/src/jit/emitarm.cpp +++ b/src/jit/emitarm.cpp @@ -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; } diff --git a/src/jit/lower.cpp b/src/jit/lower.cpp index 0752872339..4c1b543acc 100644 --- a/src/jit/lower.cpp +++ b/src/jit/lower.cpp @@ -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 diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index 40b609a0c0..178003a99f 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -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); diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index 11b1b18143..4d8e607a44 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -8587,7 +8587,7 @@ CONTRACTL { void CEEInfo::getMethodVTableOffset (CORINFO_METHOD_HANDLE methodHnd, unsigned * pOffsetOfIndirection, unsigned * pOffsetAfterIndirection, - unsigned * isRelative) + bool * isRelative) { CONTRACTL { SO_TOLERANT; diff --git a/src/vm/jitinterface.h b/src/vm/jitinterface.h index cbb24e0913..0e9075bfef 100644 --- a/src/vm/jitinterface.h +++ b/src/vm/jitinterface.h @@ -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, diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp index 2f3852398c..f8305dc194 100644 --- a/src/zap/zapinfo.cpp +++ b/src/zap/zapinfo.cpp @@ -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); } diff --git a/src/zap/zapinfo.h b/src/zap/zapinfo.h index 24ca895b6d..88f095bc2d 100644 --- a/src/zap/zapinfo.h +++ b/src/zap/zapinfo.h @@ -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, |