Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[WIP] Alternative approach to issue 47202 #77370

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6959,8 +6959,11 @@ void CodeGen::genSetScopeInfoUsingVariableRanges()
end++;
}

genSetScopeInfo(liveRangeIndex, start, end - start, varNum, varNum, true, loc);
liveRangeIndex++;
if (start < end)
{
genSetScopeInfo(liveRangeIndex, start, end - start, varNum, varNum, true, loc);
liveRangeIndex++;
}
};

siVarLoc* curLoc = nullptr;
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7718,7 +7718,12 @@ class Compiler
UNATIVE_OFFSET endOffset;
DWORD varNumber;
CodeGenInterface::siVarLoc loc;
} * eeVars;
};
// We use a temporary buffer to copy all variable debug info,
// and once we know exactly the amount of info to report,
// we ask the vm for memory and copy it.
VarResultInfo* eeJitTempVars; // temporary buffer
VarResultInfo* eeVars;
void eeSetLVcount(unsigned count);
void eeSetLVinfo(unsigned which,
UNATIVE_OFFSET startOffs,
Expand Down
27 changes: 19 additions & 8 deletions src/coreclr/jit/ee_il_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,16 +646,16 @@ void Compiler::eeSetLVcount(unsigned count)
{
assert(opts.compScopeInfo);

JITDUMP("VarLocInfo count is %d\n", count);
JITDUMP("VarLocInfo estimated count is %d\n", count);

eeVarsCount = count;
if (eeVarsCount)
{
eeVars = (VarResultInfo*)info.compCompHnd->allocateArray(eeVarsCount * sizeof(eeVars[0]));
eeJitTempVars = new (this, CMK_DebugInfo) VarResultInfo[count];
}
else
{
eeVars = nullptr;
eeJitTempVars = nullptr;
}
}

Expand All @@ -672,12 +672,12 @@ void Compiler::eeSetLVinfo(unsigned which,
assert(eeVarsCount > 0);
assert(which < eeVarsCount);

if (eeVars != nullptr)
if (eeJitTempVars != nullptr)
{
eeVars[which].startOffset = startOffs;
eeVars[which].endOffset = startOffs + length;
eeVars[which].varNumber = varNum;
eeVars[which].loc = varLoc;
eeJitTempVars[which].startOffset = startOffs;
eeJitTempVars[which].endOffset = startOffs + length;
eeJitTempVars[which].varNumber = varNum;
eeJitTempVars[which].loc = varLoc;
}
}

Expand All @@ -687,6 +687,17 @@ void Compiler::eeSetLVdone()
assert(sizeof(eeVars[0]) == sizeof(ICorDebugInfo::NativeVarInfo));
assert(opts.compScopeInfo);

if (eeVarsCount)
{
// Ask the vm for memory and copy the pre-calculated VarResultInfo into it
eeVars = (VarResultInfo*)info.compCompHnd->allocateArray(eeVarsCount * sizeof(eeVars[0]));
memcpy(eeVars, eeJitTempVars, eeVarsCount * sizeof(eeVars[0]));
}
else
{
eeVars = nullptr;
}

#ifdef DEBUG
if (verbose || opts.dspDebugInfo)
{
Expand Down