Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

allow method idx + 1 index #6425

Merged
merged 3 commits into from
Apr 5, 2019
Merged
Changes from 1 commit
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
25 changes: 10 additions & 15 deletions src/absil/ilwrite.fs
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,13 @@ type ByteBuffer with
buf.EmitByte 0x0uy

// Emit compressed untagged integer
member buf.EmitZUntaggedIndex nm sz big idx =
member buf.EmitZUntaggedIndex big idx =
if big then buf.EmitInt32 idx
elif idx > 0xffff then
#if NETSTANDARD1_6
let trace = "no stack trace on.NET Standard 1.6"
#else
let trace = (new System.Diagnostics.StackTrace()).ToString()
#endif
failwithf "EmitZUntaggedIndex: index into table '%d' is too big for small address or simple index, idx = %d, big = %A, size of table = %d, stack = %s" nm idx big sz trace
else buf.EmitInt32AsUInt16 idx
else
// idx 0x10000 is allowed for method table idx + 1 for just beyond last index of method table
if idx > 0x10000 then
System.Diagnostics.Debug.Assert (false, "EmitZUntaggedIndex: too big for small address or simple index")
buf.EmitInt32AsUInt16 idx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when an idx of 0x10000 is passed in, 0x0000 is written to buffer by this, which is identical to passing an idx of 0x0000. Is that actually what we want?


// Emit compressed tagged integer
member buf.EmitZTaggedIndex tag nbits big idx =
Expand Down Expand Up @@ -3330,12 +3327,10 @@ let writeILMetadataAndCode (generatePdb, desiredMetadataVersion, ilg, emitTailca
| _ when t = RowElementTags.ULong -> tablesBuf.EmitInt32 n
| _ when t = RowElementTags.Data -> recordRequiredDataFixup requiredDataFixups tablesBuf (tablesStreamStart + tablesBuf.Position) (n, false)
| _ when t = RowElementTags.DataResources -> recordRequiredDataFixup requiredDataFixups tablesBuf (tablesStreamStart + tablesBuf.Position) (n, true)
| _ when t = RowElementTags.Guid -> tablesBuf.EmitZUntaggedIndex -3 guidsStreamPaddedSize guidsBig (guidAddress n)
| _ when t = RowElementTags.Blob -> tablesBuf.EmitZUntaggedIndex -2 blobsStreamPaddedSize blobsBig (blobAddress n)
| _ when t = RowElementTags.String -> tablesBuf.EmitZUntaggedIndex -1 stringsStreamPaddedSize stringsBig (stringAddress n)
| _ when t <= RowElementTags.SimpleIndexMax ->
let tnum = t - RowElementTags.SimpleIndexMin
tablesBuf.EmitZUntaggedIndex tnum (size tnum) (bigness tnum) n
| _ when t = RowElementTags.Guid -> tablesBuf.EmitZUntaggedIndex guidsBig (guidAddress n)
| _ when t = RowElementTags.Blob -> tablesBuf.EmitZUntaggedIndex blobsBig (blobAddress n)
| _ when t = RowElementTags.String -> tablesBuf.EmitZUntaggedIndex stringsBig (stringAddress n)
| _ when t <= RowElementTags.SimpleIndexMax -> tablesBuf.EmitZUntaggedIndex (bigness (t - RowElementTags.SimpleIndexMin)) n
| _ when t <= RowElementTags.TypeDefOrRefOrSpecMax -> tablesBuf.EmitZTaggedIndex (t - RowElementTags.TypeDefOrRefOrSpecMin) 2 tdorBigness n
| _ when t <= RowElementTags.TypeOrMethodDefMax -> tablesBuf.EmitZTaggedIndex (t - RowElementTags.TypeOrMethodDefMin) 1 tomdBigness n
| _ when t <= RowElementTags.HasConstantMax -> tablesBuf.EmitZTaggedIndex (t - RowElementTags.HasConstantMin) 2 hcBigness n
Expand Down