Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Skip duplicate EH clauses #2288

Merged
merged 1 commit into from
Dec 2, 2016
Merged
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
38 changes: 35 additions & 3 deletions src/JitInterface/src/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,45 @@ private ObjectNode.ObjectData EncodeEHInfo()
var builder = new ObjectDataBuilder();
builder.Alignment = 1;

// TODO: Filter out duplicate clauses
int totalClauses = _ehClauses.Length;

builder.EmitCompressedUInt((uint)_ehClauses.Length);
// Count the number of special markers that will be needed
for (int i = 1; i < _ehClauses.Length; i++)
{
ref CORINFO_EH_CLAUSE clause = ref _ehClauses[i];
ref CORINFO_EH_CLAUSE previousClause = ref _ehClauses[i-1];

if ((previousClause.TryOffset == clause.TryOffset) &&
(previousClause.TryLength == clause.TryLength) &&
((clause.Flags & CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_SAMETRY) == 0))
{
totalClauses++;
}
}

builder.EmitCompressedUInt((uint)totalClauses);

for (int i = 0; i < _ehClauses.Length; i++)
{
var clause = _ehClauses[i];
ref CORINFO_EH_CLAUSE clause = ref _ehClauses[i];

if (i > 0)
{
ref CORINFO_EH_CLAUSE previousClause = ref _ehClauses[i-1];

// If the previous clause has same try offset and length as the current clause,
// but belongs to a different try block (CORINFO_EH_CLAUSE_SAMETRY is not set),
// emit a special marker to allow runtime distinguish this case.
if ((previousClause.TryOffset == clause.TryOffset) &&
(previousClause.TryLength == clause.TryLength) &&
((clause.Flags & CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_SAMETRY) == 0))
{
builder.EmitCompressedUInt(0);
builder.EmitCompressedUInt((uint)RhEHClauseKind.RH_EH_CLAUSE_FAULT);
builder.EmitCompressedUInt(0);
}
}

RhEHClauseKind clauseKind;

if (((clause.Flags & CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_FAULT) != 0) ||
Expand Down
4 changes: 3 additions & 1 deletion src/JitInterface/src/CorInfoTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,9 @@ public enum CORINFO_EH_CLAUSE_FLAGS
CORINFO_EH_CLAUSE_NONE = 0,
CORINFO_EH_CLAUSE_FILTER = 0x0001, // If this bit is on, then this EH entry is for a filter
CORINFO_EH_CLAUSE_FINALLY = 0x0002, // This clause is a finally clause
CORINFO_EH_CLAUSE_FAULT = 0x0004, // This clause is a fault clause
CORINFO_EH_CLAUSE_FAULT = 0x0004, // This clause is a fault clause
CORINFO_EH_CLAUSE_DUPLICATED = 0x0008, // Duplicated clause. This clause was duplicated to a funclet which was pulled out of line
CORINFO_EH_CLAUSE_SAMETRY = 0x0010, // This clause covers same try block as the previous one. (Used by CoreRT ABI.)
};

public struct CORINFO_EH_CLAUSE
Expand Down
12 changes: 7 additions & 5 deletions src/JitInterface/src/ThunkGenerator/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -911,10 +911,12 @@ enum CORINFO_ACCESS_FLAGS
// These are the flags set on an CORINFO_EH_CLAUSE
enum CORINFO_EH_CLAUSE_FLAGS
{
CORINFO_EH_CLAUSE_NONE = 0,
CORINFO_EH_CLAUSE_FILTER = 0x0001, // If this bit is on, then this EH entry is for a filter
CORINFO_EH_CLAUSE_FINALLY = 0x0002, // This clause is a finally clause
CORINFO_EH_CLAUSE_FAULT = 0x0004, // This clause is a fault clause
CORINFO_EH_CLAUSE_NONE = 0,
CORINFO_EH_CLAUSE_FILTER = 0x0001, // If this bit is on, then this EH entry is for a filter
CORINFO_EH_CLAUSE_FINALLY = 0x0002, // This clause is a finally clause
CORINFO_EH_CLAUSE_FAULT = 0x0004, // This clause is a fault clause
CORINFO_EH_CLAUSE_DUPLICATE = 0x0008, // Duplicated clause. This clause was duplicated to a funclet which was pulled out of line
CORINFO_EH_CLAUSE_SAMETRY = 0x0010, // This clause covers same try block as the previous one. (Used by CoreRT ABI.)
};

// This enumeration is passed to InternalThrow
Expand Down Expand Up @@ -3140,4 +3142,4 @@ class ICorDynamicInfo : public ICorStaticInfo
#define IMAGE_REL_BASED_REL32 0x10
#define IMAGE_REL_BASED_THUMB_BRANCH24 0x13

#endif // _COR_INFO_H_
#endif // _COR_INFO_H_
2 changes: 1 addition & 1 deletion src/JitInterface/src/ThunkGenerator/corjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -714,4 +714,4 @@ class ICorJitInfo : public ICorDynamicInfo
};

/**********************************************************************************/
#endif // _COR_CORJIT_H_
#endif // _COR_CORJIT_H_
8 changes: 8 additions & 0 deletions src/Runtime.Base/src/System/Runtime/ExceptionHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,10 @@ private static void DebugVerifyHandlingFrame(UIntPtr handlingFrameSP)
// previous dispatch.
if ((ehClause._tryStartOffset == lastTryStart) && (ehClause._tryEndOffset == lastTryEnd))
continue;

// We are done skipping. This is required to handle empty finally block markers that are used
// to separate runs of different try blocks with same native code offsets.
idxStart = MaxTryRegionIdx;
}

RhEHClauseKind clauseKind = ehClause._clauseKind;
Expand Down Expand Up @@ -861,6 +865,10 @@ private static void InvokeSecondPass(ref ExInfo exInfo, uint idxStart, uint idxL
// previous dispatch.
if ((ehClause._tryStartOffset == lastTryStart) && (ehClause._tryEndOffset == lastTryEnd))
continue;

// We are done skipping. This is required to handle empty finally block markers that are used
// to separate runs of different try blocks with same native code offsets.
idxStart = MaxTryRegionIdx;
}

RhEHClauseKind clauseKind = ehClause._clauseKind;
Expand Down
2 changes: 1 addition & 1 deletion src/packaging/packages.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<StaticLibExt Condition="'$(OsEnvironment)'=='Windows_NT'">lib</StaticLibExt>
<StaticLibExt Condition="'$(OsEnvironment)'!='Windows_NT'">a</StaticLibExt>

<JitPackageVersion>1.2.0-beta-24729-02</JitPackageVersion>
<JitPackageVersion>1.2.0-beta-24802-02</JitPackageVersion>

<ObjectWriterPackageVersion>1.0.13-prerelease-00001</ObjectWriterPackageVersion>
<ObjectWriterNuPkgRid Condition="'$(OSGroup)'=='Linux'">ubuntu.14.04-x64</ObjectWriterNuPkgRid>
Expand Down
2 changes: 1 addition & 1 deletion src/packaging/project.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"Microsoft.NETCore.Jit": "1.2.0-beta-24729-02",
"Microsoft.NETCore.Jit": "1.2.0-beta-24802-02",
"Microsoft.DotNet.ObjectWriter": "1.0.13-prerelease-00001"
},
"frameworks": {
Expand Down
1 change: 1 addition & 0 deletions tests/Top200.CoreCLR.issues.targets
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
<IncludeList Include="$(XunitTestBinBase)\JIT\Directed\nullabletypes\isinst_do\isinst_do.cmd" />
<IncludeList Include="$(XunitTestBinBase)\JIT\Regression\JitBlue\DevDiv_142976\DevDiv_142976\DevDiv_142976.cmd" />
<IncludeList Include="$(XunitTestBinBase)\JIT\jit64\localloc\eh\eh01_dynamic\eh01_dynamic.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Loader\classloader\TypeInitialization\CctorsWithSideEffects\CctorThrowStaticField\CctorThrowStaticField.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Loader\classloader\generics\Layout\General\Base01a_auto\Base01a_auto.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Loader\classloader\generics\Layout\General\Base01a_auto_ser\Base01a_auto_ser.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Loader\classloader\generics\Layout\General\Base01a_seq\Base01a_seq.cmd" />
Expand Down