Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
8a0a65f0
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8a0a65f0
编写于
7月 14, 2015
作者:
T
Tomáš Matoušek
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3943 from tmat/BlobBuilderRename
Rename BlobWriter to BlobBuilder
上级
06b99644
6d305d17
变更
21
展开全部
隐藏空白更改
内联
并排
Showing
21 changed file
with
244 addition
and
227 deletion
+244
-227
src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs
...Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs
+2
-2
src/Compilers/Core/CodeAnalysisTest/CodeAnalysisTest.csproj
src/Compilers/Core/CodeAnalysisTest/CodeAnalysisTest.csproj
+1
-0
src/Compilers/Core/CodeAnalysisTest/Emit/CustomDebugInfoTests.cs
...pilers/Core/CodeAnalysisTest/Emit/CustomDebugInfoTests.cs
+5
-5
src/Compilers/Core/CodeAnalysisTest/PEWriter/BlobWriterTests.cs
...mpilers/Core/CodeAnalysisTest/PEWriter/BlobWriterTests.cs
+7
-7
src/Compilers/Core/Portable/CodeGen/BasicBlock.cs
src/Compilers/Core/Portable/CodeGen/BasicBlock.cs
+7
-24
src/Compilers/Core/Portable/CodeGen/ILBuilder.cs
src/Compilers/Core/Portable/CodeGen/ILBuilder.cs
+1
-1
src/Compilers/Core/Portable/CodeGen/ILBuilderEmit.cs
src/Compilers/Core/Portable/CodeGen/ILBuilderEmit.cs
+2
-2
src/Compilers/Core/Portable/Collections/ByteSequenceComparer.cs
...mpilers/Core/Portable/Collections/ByteSequenceComparer.cs
+29
-5
src/Compilers/Core/Portable/ConstantValue.cs
src/Compilers/Core/Portable/ConstantValue.cs
+1
-1
src/Compilers/Core/Portable/Emit/EditAndContinue/DeltaMetadataWriter.cs
...Core/Portable/Emit/EditAndContinue/DeltaMetadataWriter.cs
+1
-1
src/Compilers/Core/Portable/Emit/EditAndContinueMethodDebugInformation.cs
...re/Portable/Emit/EditAndContinueMethodDebugInformation.cs
+2
-2
src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs
src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs
+2
-2
src/Compilers/Core/Portable/PEWriter/BlobWriter.cs
src/Compilers/Core/Portable/PEWriter/BlobWriter.cs
+20
-11
src/Compilers/Core/Portable/PEWriter/CustomDebugInfoWriter.cs
...Compilers/Core/Portable/PEWriter/CustomDebugInfoWriter.cs
+20
-20
src/Compilers/Core/Portable/PEWriter/ManagedResource.cs
src/Compilers/Core/Portable/PEWriter/ManagedResource.cs
+1
-1
src/Compilers/Core/Portable/PEWriter/MetadataHeapsBuilder.cs
src/Compilers/Core/Portable/PEWriter/MetadataHeapsBuilder.cs
+10
-10
src/Compilers/Core/Portable/PEWriter/MetadataWriter.PortablePdb.cs
...lers/Core/Portable/PEWriter/MetadataWriter.PortablePdb.cs
+20
-20
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
+86
-86
src/Compilers/Core/Portable/PEWriter/PeWriter.cs
src/Compilers/Core/Portable/PEWriter/PeWriter.cs
+21
-21
src/Compilers/VisualBasic/Portable/CodeGen/EmitArrayInitializer.vb
...lers/VisualBasic/Portable/CodeGen/EmitArrayInitializer.vb
+2
-2
src/Test/Utilities/ILBuilderVisualizer.cs
src/Test/Utilities/ILBuilderVisualizer.cs
+4
-4
未找到文件。
src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs
浏览文件 @
8a0a65f0
...
...
@@ -310,14 +310,14 @@ private ImmutableArray<byte> GetRawData(ImmutableArray<BoundExpression> initiali
// the initial size is a guess.
// there is no point to be precise here as MemoryStream always has N + 1 storage
// and will need to be trimmed regardless
var
writer
=
new
Cci
.
Blob
Writ
er
(
initializers
.
Length
*
4
);
var
writer
=
new
Cci
.
Blob
Build
er
(
initializers
.
Length
*
4
);
SerializeArrayRecursive
(
writer
,
initializers
);
return
writer
.
ToImmutableArray
();
}
private
void
SerializeArrayRecursive
(
Cci
.
Blob
Writ
er
bw
,
ImmutableArray
<
BoundExpression
>
inits
)
private
void
SerializeArrayRecursive
(
Cci
.
Blob
Build
er
bw
,
ImmutableArray
<
BoundExpression
>
inits
)
{
if
(
inits
.
Length
!=
0
)
{
...
...
src/Compilers/Core/CodeAnalysisTest/CodeAnalysisTest.csproj
浏览文件 @
8a0a65f0
...
...
@@ -25,6 +25,7 @@
<Compile
Include=
"AssemblyUtilitiesTests.cs"
/>
<Compile
Include=
"AsyncQueueTests.cs"
/>
<Compile
Include=
"Collections\BoxesTest.cs"
/>
<Compile
Include=
"Collections\ByteSequenceComparerTests.cs"
/>
<Compile
Include=
"Diagnostics\DiagnosticLocalizationTests.cs"
/>
<Compile
Include=
"Emit\EmitOptionsTests.cs"
/>
<Compile
Include=
"Emit\CustomDebugInfoTests.cs"
/>
...
...
src/Compilers/Core/CodeAnalysisTest/Emit/CustomDebugInfoTests.cs
浏览文件 @
8a0a65f0
...
...
@@ -196,7 +196,7 @@ public void EditAndContinueLocalSlotMap_NegativeSyntaxOffsets()
var
closures
=
ImmutableArray
<
ClosureDebugInfo
>.
Empty
;
var
lambdas
=
ImmutableArray
<
LambdaDebugInfo
>.
Empty
;
var
cmw
=
new
Cci
.
Blob
Writ
er
();
var
cmw
=
new
Cci
.
Blob
Build
er
();
new
EditAndContinueMethodDebugInformation
(
123
,
slots
,
closures
,
lambdas
).
SerializeLocalSlots
(
cmw
);
...
...
@@ -223,7 +223,7 @@ public void EditAndContinueLambdaAndClosureMap_NegativeSyntaxOffsets()
new
LambdaDebugInfo
(-
50
,
new
DebugId
(
1
,
0
),
0
),
new
LambdaDebugInfo
(-
180
,
new
DebugId
(
2
,
0
),
LambdaDebugInfo
.
StaticClosureOrdinal
));
var
cmw
=
new
Cci
.
Blob
Writ
er
();
var
cmw
=
new
Cci
.
Blob
Build
er
();
new
EditAndContinueMethodDebugInformation
(
0x7b
,
slots
,
closures
,
lambdas
).
SerializeLambdaMap
(
cmw
);
...
...
@@ -245,7 +245,7 @@ public void EditAndContinueLambdaAndClosureMap_NoClosures()
var
closures
=
ImmutableArray
<
ClosureDebugInfo
>.
Empty
;
var
lambdas
=
ImmutableArray
.
Create
(
new
LambdaDebugInfo
(
20
,
new
DebugId
(
0
,
0
),
LambdaDebugInfo
.
StaticClosureOrdinal
));
var
cmw
=
new
Cci
.
Blob
Writ
er
();
var
cmw
=
new
Cci
.
Blob
Build
er
();
new
EditAndContinueMethodDebugInformation
(-
1
,
slots
,
closures
,
lambdas
).
SerializeLambdaMap
(
cmw
);
...
...
@@ -268,7 +268,7 @@ public void EditAndContinueLambdaAndClosureMap_NoLambdas()
var
closures
=
ImmutableArray
<
ClosureDebugInfo
>.
Empty
;
var
lambdas
=
ImmutableArray
<
LambdaDebugInfo
>.
Empty
;
var
cmw
=
new
Cci
.
Blob
Writ
er
();
var
cmw
=
new
Cci
.
Blob
Build
er
();
new
EditAndContinueMethodDebugInformation
(
10
,
slots
,
closures
,
lambdas
).
SerializeLambdaMap
(
cmw
);
...
...
@@ -300,7 +300,7 @@ public void EncCdiAlignment()
new
LambdaDebugInfo
(-
180
,
new
DebugId
(
2
,
0
),
LambdaDebugInfo
.
StaticClosureOrdinal
));
var
debugInfo
=
new
EditAndContinueMethodDebugInformation
(
1
,
slots
,
closures
,
lambdas
);
var
records
=
new
ArrayBuilder
<
Cci
.
Blob
Writ
er
>();
var
records
=
new
ArrayBuilder
<
Cci
.
Blob
Build
er
>();
Cci
.
CustomDebugInfoWriter
.
SerializeCustomDebugInformation
(
debugInfo
,
records
);
var
cdi
=
Cci
.
CustomDebugInfoWriter
.
SerializeCustomDebugMetadata
(
records
);
...
...
src/Compilers/Core/CodeAnalysisTest/PEWriter/BlobWriterTests.cs
浏览文件 @
8a0a65f0
...
...
@@ -12,14 +12,14 @@ public class BlobWriterTests
{
private
static
byte
[]
CompressUnsignedInteger
(
int
value
)
{
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
writer
.
WriteCompressedInteger
((
uint
)
value
);
return
writer
.
ToArray
();
}
private
static
byte
[]
CompressSignedInteger
(
int
value
)
{
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
writer
.
WriteCompressedSignedInteger
(
value
);
return
writer
.
ToArray
();
}
...
...
@@ -59,7 +59,7 @@ public void CompressSignedIntegersFromSpecExamples()
[
Fact
]
public
void
WritePrimitive
()
{
var
writer
=
new
Blob
Writ
er
(
4
);
var
writer
=
new
Blob
Build
er
(
4
);
writer
.
WriteUInt32
(
0x11223344
);
writer
.
WriteUInt16
(
0x5566
);
...
...
@@ -98,7 +98,7 @@ public void WritePrimitive()
[
Fact
]
public
void
WriteBytes1
()
{
var
writer
=
new
Blob
Writ
er
(
4
);
var
writer
=
new
Blob
Build
er
(
4
);
writer
.
WriteBytes
(
new
byte
[]
{
1
,
2
,
3
,
4
});
writer
.
WriteBytes
(
new
byte
[]
{
});
...
...
@@ -123,7 +123,7 @@ public void WriteBytes1()
[
Fact
]
public
void
WriteBytes2
()
{
var
writer
=
new
Blob
Writ
er
(
4
);
var
writer
=
new
Blob
Build
er
(
4
);
writer
.
WriteBytes
(
0xff
,
0
);
writer
.
WriteBytes
(
1
,
4
);
...
...
@@ -143,7 +143,7 @@ public void WriteBytes2()
[
Fact
]
public
void
WriteAlignPad
()
{
var
writer
=
new
Blob
Writ
er
(
4
);
var
writer
=
new
Blob
Build
er
(
4
);
writer
.
WriteByte
(
0x01
);
writer
.
PadTo
(
2
);
...
...
@@ -174,7 +174,7 @@ public void WriteAlignPad()
[
Fact
]
public
void
WriteUTF8
()
{
var
writer
=
new
Blob
Writ
er
(
4
);
var
writer
=
new
Blob
Build
er
(
4
);
writer
.
WriteUTF8
(
"a"
);
writer
.
WriteUTF8
(
""
);
writer
.
WriteUTF8
(
"bc"
);
...
...
src/Compilers/Core/Portable/CodeGen/BasicBlock.cs
浏览文件 @
8a0a65f0
...
...
@@ -73,14 +73,14 @@ internal void Initialize(ILBuilder builder)
//parent builder
internal
ILBuilder
builder
;
private
Cci
.
Blob
Writ
er
_lazyRegularInstructions
;
public
Cci
.
Blob
Writ
er
Writer
private
Cci
.
Blob
Build
er
_lazyRegularInstructions
;
public
Cci
.
Blob
Build
er
Writer
{
get
{
if
(
_lazyRegularInstructions
==
null
)
{
_lazyRegularInstructions
=
Cci
.
Blob
Writ
er
.
GetInstance
();
_lazyRegularInstructions
=
Cci
.
Blob
Build
er
.
GetInstance
();
}
return
_lazyRegularInstructions
;
...
...
@@ -248,7 +248,7 @@ private bool IsBranchToLabel
/// <summary>
/// Instructions that are not branches.
/// </summary>
public
Cci
.
Blob
Writ
er
RegularInstructions
=>
_lazyRegularInstructions
;
public
Cci
.
Blob
Build
er
RegularInstructions
=>
_lazyRegularInstructions
;
/// <summary>
/// The block contains only the final branch or nothing at all
...
...
@@ -533,34 +533,17 @@ private bool TryOptimizeBranchToEquivalent(BasicBlock next, ref int delta)
private
static
bool
AreIdentical
(
BasicBlock
one
,
BasicBlock
another
)
{
if
(
one
.
_branchCode
==
another
.
_branchCode
&&
!
one
.
_branchCode
.
CanFallThrough
()
&&
one
.
_branchLabel
==
another
.
_branchLabel
)
!
one
.
_branchCode
.
CanFallThrough
()
&&
one
.
_branchLabel
==
another
.
_branchLabel
)
{
var
instr1
=
one
.
RegularInstructions
;
var
instr2
=
another
.
RegularInstructions
;
if
(
instr1
==
instr2
)
{
return
true
;
}
if
(
instr1
!=
null
&&
instr2
!=
null
&&
instr1
.
Length
==
instr2
.
Length
)
{
for
(
int
i
=
0
,
l
=
(
int
)
instr1
.
Length
;
i
<
l
;
i
++)
{
if
(
instr1
.
Buffer
[
i
]
!=
instr2
.
Buffer
[
i
])
{
return
false
;
}
}
return
true
;
}
return
instr1
==
instr2
||
instr1
?.
ContentEquals
(
instr2
)
==
true
;
}
return
false
;
}
/// <summary>
/// Returns reversed branch operation for the current block.
/// If no reverse opcode can be obtained Nop is returned.
...
...
src/Compilers/Core/Portable/CodeGen/ILBuilder.cs
浏览文件 @
8a0a65f0
...
...
@@ -864,7 +864,7 @@ private void RealizeBlocks()
}
// Now linearize everything with computed offsets.
var
writer
=
Cci
.
Blob
Writ
er
.
GetInstance
();
var
writer
=
Cci
.
Blob
Build
er
.
GetInstance
();
for
(
var
block
=
leaderBlock
;
block
!=
null
;
block
=
block
.
NextBlock
)
{
...
...
src/Compilers/Core/Portable/CodeGen/ILBuilderEmit.cs
浏览文件 @
8a0a65f0
...
...
@@ -704,7 +704,7 @@ private void EmitDouble(double doubleValue)
this
.
GetCurrentWriter
().
WriteInt64
(
int64
);
}
private
static
void
WriteOpCode
(
Cci
.
Blob
Writ
er
writer
,
ILOpCode
code
)
private
static
void
WriteOpCode
(
Cci
.
Blob
Build
er
writer
,
ILOpCode
code
)
{
var
size
=
code
.
Size
();
if
(
size
==
1
)
...
...
@@ -724,7 +724,7 @@ private static void WriteOpCode(Cci.BlobWriter writer, ILOpCode code)
}
}
private
Cci
.
Blob
Writ
er
GetCurrentWriter
()
private
Cci
.
Blob
Build
er
GetCurrentWriter
()
{
return
this
.
GetCurrentBlock
().
Writer
;
}
...
...
src/Compilers/Core/Portable/Collections/ByteSequenceComparer.cs
浏览文件 @
8a0a65f0
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
...
...
@@ -40,21 +41,44 @@ internal static bool Equals(ImmutableArray<byte> x, ImmutableArray<byte> y)
return
true
;
}
internal
static
bool
Equals
(
byte
[]
x
,
byte
[]
y
)
internal
static
bool
Equals
(
byte
[]
left
,
int
leftStart
,
byte
[]
right
,
int
rightStart
,
int
length
)
{
if
(
ReferenceEquals
(
x
,
y
))
if
(
left
==
null
||
right
==
null
)
{
return
ReferenceEquals
(
left
,
right
);
}
if
(
ReferenceEquals
(
left
,
right
)
&&
leftStart
==
rightStart
)
{
return
true
;
}
if
(
x
==
null
||
y
==
null
||
x
.
Length
!=
y
.
Length
)
for
(
var
i
=
0
;
i
<
length
;
i
++)
{
if
(
left
[
leftStart
+
i
]
!=
right
[
rightStart
+
i
])
{
return
false
;
}
}
return
true
;
}
internal
static
bool
Equals
(
byte
[]
left
,
byte
[]
right
)
{
if
(
ReferenceEquals
(
left
,
right
))
{
return
true
;
}
if
(
left
==
null
||
right
==
null
||
left
.
Length
!=
right
.
Length
)
{
return
false
;
}
for
(
var
i
=
0
;
i
<
x
.
Length
;
i
++)
for
(
var
i
=
0
;
i
<
left
.
Length
;
i
++)
{
if
(
x
[
i
]
!=
y
[
i
])
if
(
left
[
i
]
!=
right
[
i
])
{
return
false
;
}
...
...
src/Compilers/Core/Portable/ConstantValue.cs
浏览文件 @
8a0a65f0
...
...
@@ -662,7 +662,7 @@ public bool IsNothing
}
}
public
void
Serialize
(
Cci
.
Blob
Writ
er
writer
)
public
void
Serialize
(
Cci
.
Blob
Build
er
writer
)
{
switch
(
this
.
Discriminator
)
{
...
...
src/Compilers/Core/Portable/Emit/EditAndContinue/DeltaMetadataWriter.cs
浏览文件 @
8a0a65f0
...
...
@@ -609,7 +609,7 @@ protected override int SerializeLocalVariablesSignature(IMethodBody body)
if
(
localVariables
.
Length
>
0
)
{
var
writer
=
Blob
Writ
er
.
GetInstance
();
var
writer
=
Blob
Build
er
.
GetInstance
();
writer
.
WriteByte
(
0x07
);
writer
.
WriteCompressedInteger
((
uint
)
localVariables
.
Length
);
...
...
src/Compilers/Core/Portable/Emit/EditAndContinueMethodDebugInformation.cs
浏览文件 @
8a0a65f0
...
...
@@ -121,7 +121,7 @@ private unsafe static ImmutableArray<LocalSlotDebugInfo> UncompressSlotMap(Immut
return
mapBuilder
.
ToImmutableAndFree
();
}
internal
void
SerializeLocalSlots
(
Cci
.
Blob
Writ
er
writer
)
internal
void
SerializeLocalSlots
(
Cci
.
Blob
Build
er
writer
)
{
int
syntaxOffsetBaseline
=
-
1
;
foreach
(
LocalSlotDebugInfo
localSlot
in
this
.
LocalSlots
)
...
...
@@ -237,7 +237,7 @@ internal void SerializeLocalSlots(Cci.BlobWriter writer)
lambdas
=
lambdasBuilder
.
ToImmutableAndFree
();
}
internal
void
SerializeLambdaMap
(
Cci
.
Blob
Writ
er
writer
)
internal
void
SerializeLambdaMap
(
Cci
.
Blob
Build
er
writer
)
{
Debug
.
Assert
(
this
.
MethodOrdinal
>=
-
1
);
writer
.
WriteCompressedInteger
((
uint
)(
this
.
MethodOrdinal
+
1
));
...
...
src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs
浏览文件 @
8a0a65f0
...
...
@@ -48,7 +48,7 @@ internal sealed class PdbLogger
// On the other hand, we do want to use a fairly large buffer as the hashing operations
// are invoked through reflection, which is fairly slow.
private
readonly
bool
_logging
;
private
readonly
Blob
Writ
er
_logData
;
private
readonly
Blob
Build
er
_logData
;
private
const
int
bufferFlushLimit
=
64
*
1024
;
private
readonly
HashAlgorithm
_hashAlgorithm
;
...
...
@@ -57,7 +57,7 @@ internal PdbLogger(bool logging)
_logging
=
logging
;
if
(
logging
)
{
_logData
=
Blob
Writ
er
.
GetInstance
();
_logData
=
Blob
Build
er
.
GetInstance
();
_hashAlgorithm
=
new
SHA1CryptoServiceProvider
();
Debug
.
Assert
(
_hashAlgorithm
.
SupportsTransform
);
}
...
...
src/Compilers/Core/Portable/PEWriter/BlobWriter.cs
浏览文件 @
8a0a65f0
...
...
@@ -8,17 +8,18 @@
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
Microsoft.CodeAnalysis.Collections
;
using
Roslyn.Utilities
;
namespace
Microsoft.Cci
{
internal
unsafe
sealed
class
Blob
Writ
er
internal
unsafe
sealed
class
Blob
Build
er
{
private
byte
[]
_buffer
;
private
int
_length
;
private
int
_position
;
internal
Blob
Writ
er
(
int
initialSize
=
64
)
internal
Blob
Build
er
(
int
initialSize
=
64
)
{
// the writer assumes little-endian architecture:
Debug
.
Assert
(
BitConverter
.
IsLittleEndian
);
...
...
@@ -26,12 +27,20 @@ internal BlobWriter(int initialSize = 64)
_buffer
=
new
byte
[
initialSize
];
}
internal
Blob
Writer
(
ObjectPool
<
BlobWrit
er
>
pool
)
internal
Blob
Builder
(
ObjectPool
<
BlobBuild
er
>
pool
)
:
this
()
{
_pool
=
pool
;
}
/// <summary>
/// Compares the current content of this writer with another one.
/// </summary>
public
bool
ContentEquals
(
BlobBuilder
other
)
{
return
other
!=
null
&&
Length
==
other
.
Length
&&
ByteSequenceComparer
.
Equals
(
_buffer
,
0
,
other
.
_buffer
,
0
,
Length
);
}
public
byte
[]
Buffer
=>
_buffer
;
public
int
Length
=>
_length
;
...
...
@@ -643,7 +652,7 @@ public void WriteConstant(object value)
}
}
internal
void
WriteTo
(
Blob
Writ
er
stream
)
internal
void
WriteTo
(
Blob
Build
er
stream
)
{
stream
.
WriteBytes
(
_buffer
,
0
,
_length
);
}
...
...
@@ -662,7 +671,7 @@ internal void Clear()
#
region
Poolable
private
readonly
ObjectPool
<
Blob
Writ
er
>
_pool
;
private
readonly
ObjectPool
<
Blob
Build
er
>
_pool
;
//
// To implement Poolable, you need two things:
...
...
@@ -685,23 +694,23 @@ public void Free()
}
//2) Expose the way to get an instance.
private
static
readonly
ObjectPool
<
Blob
Writ
er
>
s_poolInstance
=
CreatePool
();
private
static
readonly
ObjectPool
<
Blob
Build
er
>
s_poolInstance
=
CreatePool
();
public
static
Blob
Writ
er
GetInstance
()
public
static
Blob
Build
er
GetInstance
()
{
var
stream
=
s_poolInstance
.
Allocate
();
return
stream
;
}
public
static
ObjectPool
<
Blob
Writ
er
>
CreatePool
()
public
static
ObjectPool
<
Blob
Build
er
>
CreatePool
()
{
return
CreatePool
(
32
);
}
public
static
ObjectPool
<
Blob
Writ
er
>
CreatePool
(
int
size
)
public
static
ObjectPool
<
Blob
Build
er
>
CreatePool
(
int
size
)
{
ObjectPool
<
Blob
Writ
er
>
pool
=
null
;
pool
=
new
ObjectPool
<
Blob
Writer
>(()
=>
new
BlobWrit
er
(
pool
),
size
);
ObjectPool
<
Blob
Build
er
>
pool
=
null
;
pool
=
new
ObjectPool
<
Blob
Builder
>(()
=>
new
BlobBuild
er
(
pool
),
size
);
return
pool
;
}
...
...
src/Compilers/Core/Portable/PEWriter/CustomDebugInfoWriter.cs
浏览文件 @
8a0a65f0
...
...
@@ -78,7 +78,7 @@ public byte[] SerializeMethodDebugInfo(EmitContext context, IMethodBody methodBo
}
}
var
customDebugInfo
=
ArrayBuilder
<
Blob
Writ
er
>.
GetInstance
();
var
customDebugInfo
=
ArrayBuilder
<
Blob
Build
er
>.
GetInstance
();
SerializeIteratorClassMetadata
(
methodBody
,
customDebugInfo
);
...
...
@@ -114,7 +114,7 @@ public byte[] SerializeMethodDebugInfo(EmitContext context, IMethodBody methodBo
}
// internal for testing
internal
static
void
SerializeCustomDebugInformation
(
EditAndContinueMethodDebugInformation
debugInfo
,
ArrayBuilder
<
Blob
Writ
er
>
customDebugInfo
)
internal
static
void
SerializeCustomDebugInformation
(
EditAndContinueMethodDebugInformation
debugInfo
,
ArrayBuilder
<
Blob
Build
er
>
customDebugInfo
)
{
if
(!
debugInfo
.
LocalSlots
.
IsDefaultOrEmpty
)
{
...
...
@@ -127,9 +127,9 @@ internal static void SerializeCustomDebugInformation(EditAndContinueMethodDebugI
}
}
private
static
Blob
Writer
SerializeRecord
(
byte
kind
,
Action
<
BlobWrit
er
>
data
)
private
static
Blob
Builder
SerializeRecord
(
byte
kind
,
Action
<
BlobBuild
er
>
data
)
{
var
cmw
=
new
Blob
Writ
er
();
var
cmw
=
new
Blob
Build
er
();
cmw
.
WriteByte
(
CDI
.
CdiVersion
);
cmw
.
WriteByte
(
kind
);
cmw
.
WriteByte
(
0
);
...
...
@@ -160,15 +160,15 @@ private static BlobWriter SerializeRecord(byte kind, Action<BlobWriter> data)
return
cmw
;
}
private
static
void
SerializeIteratorClassMetadata
(
IMethodBody
methodBody
,
ArrayBuilder
<
Blob
Writ
er
>
customDebugInfo
)
private
static
void
SerializeIteratorClassMetadata
(
IMethodBody
methodBody
,
ArrayBuilder
<
Blob
Build
er
>
customDebugInfo
)
{
SerializeReferenceToIteratorClass
(
methodBody
.
StateMachineTypeName
,
customDebugInfo
);
}
private
static
void
SerializeReferenceToIteratorClass
(
string
iteratorClassName
,
ArrayBuilder
<
Blob
Writ
er
>
customDebugInfo
)
private
static
void
SerializeReferenceToIteratorClass
(
string
iteratorClassName
,
ArrayBuilder
<
Blob
Build
er
>
customDebugInfo
)
{
if
(
iteratorClassName
==
null
)
return
;
var
cmw
=
new
Blob
Writ
er
();
var
cmw
=
new
Blob
Build
er
();
cmw
.
WriteByte
(
CDI
.
CdiVersion
);
cmw
.
WriteByte
(
CDI
.
CdiKindForwardIterator
);
cmw
.
Align
(
4
);
...
...
@@ -182,7 +182,7 @@ private static void SerializeReferenceToIteratorClass(string iteratorClassName,
customDebugInfo
.
Add
(
cmw
);
}
private
static
void
SerializeStateMachineLocalScopes
(
IMethodBody
methodBody
,
ArrayBuilder
<
Blob
Writ
er
>
customDebugInfo
)
private
static
void
SerializeStateMachineLocalScopes
(
IMethodBody
methodBody
,
ArrayBuilder
<
Blob
Build
er
>
customDebugInfo
)
{
var
scopes
=
methodBody
.
StateMachineHoistedLocalScopes
;
if
(
scopes
.
IsDefaultOrEmpty
)
...
...
@@ -191,7 +191,7 @@ private static void SerializeStateMachineLocalScopes(IMethodBody methodBody, Arr
}
uint
numberOfScopes
=
(
uint
)
scopes
.
Length
;
var
cmw
=
new
Blob
Writ
er
();
var
cmw
=
new
Blob
Build
er
();
cmw
.
WriteByte
(
CDI
.
CdiVersion
);
cmw
.
WriteByte
(
CDI
.
CdiKindStateMachineHoistedLocalScopes
);
cmw
.
Align
(
4
);
...
...
@@ -215,7 +215,7 @@ private static void SerializeStateMachineLocalScopes(IMethodBody methodBody, Arr
customDebugInfo
.
Add
(
cmw
);
}
private
static
void
SerializeDynamicLocalInfo
(
IMethodBody
methodBody
,
ArrayBuilder
<
Blob
Writ
er
>
customDebugInfo
)
private
static
void
SerializeDynamicLocalInfo
(
IMethodBody
methodBody
,
ArrayBuilder
<
Blob
Build
er
>
customDebugInfo
)
{
if
(!
methodBody
.
HasDynamicLocalVariables
)
{
...
...
@@ -248,7 +248,7 @@ private static void SerializeDynamicLocalInfo(IMethodBody methodBody, ArrayBuild
Debug
.
Assert
(
dynamicLocals
.
Any
());
// There must be at least one dynamic local if this point is reached
const
int
blobSize
=
200
;
//DynamicAttribute - 64, DynamicAttributeLength - 4, SlotIndex -4, IdentifierName - 128
var
cmw
=
new
Blob
Writ
er
();
var
cmw
=
new
Blob
Build
er
();
cmw
.
WriteByte
(
CDI
.
CdiVersion
);
cmw
.
WriteByte
(
CDI
.
CdiKindDynamicLocals
);
cmw
.
Align
(
4
);
...
...
@@ -307,18 +307,18 @@ private static void SerializeDynamicLocalInfo(IMethodBody methodBody, ArrayBuild
}
// internal for testing
internal
static
byte
[]
SerializeCustomDebugMetadata
(
ArrayBuilder
<
Blob
Writ
er
>
recordWriters
)
internal
static
byte
[]
SerializeCustomDebugMetadata
(
ArrayBuilder
<
Blob
Build
er
>
recordWriters
)
{
if
(
recordWriters
.
Count
==
0
)
{
return
null
;
}
Blob
Writer
cmw
=
BlobWrit
er
.
GetInstance
();
Blob
Builder
cmw
=
BlobBuild
er
.
GetInstance
();
cmw
.
WriteByte
(
CDI
.
CdiVersion
);
cmw
.
WriteByte
((
byte
)
recordWriters
.
Count
);
// count
cmw
.
Align
(
4
);
foreach
(
Blob
Writ
er
recordWriter
in
recordWriters
)
foreach
(
Blob
Build
er
recordWriter
in
recordWriters
)
{
recordWriter
.
WriteTo
(
cmw
);
}
...
...
@@ -328,7 +328,7 @@ internal static byte[] SerializeCustomDebugMetadata(ArrayBuilder<BlobWriter> rec
return
result
;
}
private
void
SerializeNamespaceScopeMetadata
(
EmitContext
context
,
IMethodBody
methodBody
,
ArrayBuilder
<
Blob
Writ
er
>
customDebugInfo
)
private
void
SerializeNamespaceScopeMetadata
(
EmitContext
context
,
IMethodBody
methodBody
,
ArrayBuilder
<
Blob
Build
er
>
customDebugInfo
)
{
if
(
context
.
Module
.
GenerateVisualBasicStylePdb
)
{
...
...
@@ -343,7 +343,7 @@ private void SerializeNamespaceScopeMetadata(EmitContext context, IMethodBody me
}
List
<
ushort
>
usingCounts
=
new
List
<
ushort
>();
var
cmw
=
new
Blob
Writ
er
();
var
cmw
=
new
Blob
Build
er
();
for
(
IImportScope
scope
=
methodBody
.
ImportScope
;
scope
!=
null
;
scope
=
scope
.
Parent
)
{
usingCounts
.
Add
((
ushort
)
scope
.
GetUsedNamespaces
().
Length
);
...
...
@@ -421,9 +421,9 @@ private bool ShouldForwardToPreviousMethodWithUsingInfo(EmitContext context, IMe
return
s1
==
s2
;
}
private
void
SerializeReferenceToMethodWithModuleInfo
(
ArrayBuilder
<
Blob
Writ
er
>
customDebugInfo
)
private
void
SerializeReferenceToMethodWithModuleInfo
(
ArrayBuilder
<
Blob
Build
er
>
customDebugInfo
)
{
Blob
Writer
cmw
=
new
BlobWrit
er
(
12
);
Blob
Builder
cmw
=
new
BlobBuild
er
(
12
);
cmw
.
WriteByte
(
CDI
.
CdiVersion
);
cmw
.
WriteByte
(
CDI
.
CdiKindForwardToModuleInfo
);
cmw
.
Align
(
4
);
...
...
@@ -432,9 +432,9 @@ private void SerializeReferenceToMethodWithModuleInfo(ArrayBuilder<BlobWriter> c
customDebugInfo
.
Add
(
cmw
);
}
private
void
SerializeReferenceToPreviousMethodWithUsingInfo
(
ArrayBuilder
<
Blob
Writ
er
>
customDebugInfo
)
private
void
SerializeReferenceToPreviousMethodWithUsingInfo
(
ArrayBuilder
<
Blob
Build
er
>
customDebugInfo
)
{
Blob
Writer
cmw
=
new
BlobWrit
er
(
12
);
Blob
Builder
cmw
=
new
BlobBuild
er
(
12
);
cmw
.
WriteByte
(
CDI
.
CdiVersion
);
cmw
.
WriteByte
(
CDI
.
CdiKindForwardInfo
);
cmw
.
Align
(
4
);
...
...
src/Compilers/Core/Portable/PEWriter/ManagedResource.cs
浏览文件 @
8a0a65f0
...
...
@@ -32,7 +32,7 @@ internal ManagedResource(string name, bool isPublic, Func<Stream> streamProvider
_isPublic
=
isPublic
;
}
public
void
WriteData
(
Blob
Writ
er
resourceWriter
)
public
void
WriteData
(
Blob
Build
er
resourceWriter
)
{
if
(
_fileReference
==
null
)
{
...
...
src/Compilers/Core/Portable/PEWriter/MetadataHeapsBuilder.cs
浏览文件 @
8a0a65f0
...
...
@@ -98,13 +98,13 @@ internal sealed class MetadataHeapsBuilder
// #US heap
private
readonly
Dictionary
<
string
,
int
>
_userStrings
=
new
Dictionary
<
string
,
int
>();
private
readonly
Blob
Writer
_userStringWriter
=
new
BlobWrit
er
(
1024
);
private
readonly
Blob
Builder
_userStringWriter
=
new
BlobBuild
er
(
1024
);
private
readonly
int
_userStringHeapStartOffset
;
// #String heap
private
Dictionary
<
string
,
StringIdx
>
_strings
=
new
Dictionary
<
string
,
StringIdx
>(
128
);
private
int
[]
_stringIndexToHeapPositionMap
;
private
Blob
Writ
er
_stringWriter
;
private
Blob
Build
er
_stringWriter
;
private
readonly
int
_stringHeapStartOffset
;
// #Blob heap
...
...
@@ -114,7 +114,7 @@ internal sealed class MetadataHeapsBuilder
// #GUID heap
private
readonly
Dictionary
<
Guid
,
int
>
_guids
=
new
Dictionary
<
Guid
,
int
>();
private
readonly
Blob
Writer
_guidWriter
=
new
BlobWrit
er
(
16
);
// full metadata has just a single guid
private
readonly
Blob
Builder
_guidWriter
=
new
BlobBuild
er
(
16
);
// full metadata has just a single guid
private
bool
_streamsAreComplete
;
...
...
@@ -144,7 +144,7 @@ internal sealed class MetadataHeapsBuilder
_guidWriter
.
WriteBytes
(
0
,
guidHeapStartOffset
);
}
internal
BlobIdx
GetBlobIndex
(
Blob
Writ
er
stream
)
internal
BlobIdx
GetBlobIndex
(
Blob
Build
er
stream
)
{
// TODO: avoid making a copy if the blob exists in the index
return
GetBlobIndex
(
stream
.
ToImmutableArray
());
...
...
@@ -160,7 +160,7 @@ internal BlobIdx GetBlobIndex(ImmutableArray<byte> blob)
index
=
new
BlobIdx
(
_blobHeapSize
);
_blobs
.
Add
(
blob
,
index
);
_blobHeapSize
+=
Blob
Writ
er
.
GetCompressedIntegerSize
(
blob
.
Length
)
+
blob
.
Length
;
_blobHeapSize
+=
Blob
Build
er
.
GetCompressedIntegerSize
(
blob
.
Length
)
+
blob
.
Length
;
}
return
index
;
...
...
@@ -174,7 +174,7 @@ public BlobIdx GetConstantBlobIndex(object value)
return
this
.
GetBlobIndex
(
str
);
}
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
writer
.
WriteConstant
(
value
);
return
this
.
GetBlobIndex
(
writer
);
}
...
...
@@ -361,7 +361,7 @@ private void SerializeStringHeap()
sorted
.
Sort
(
new
SuffixSort
());
_strings
=
null
;
_stringWriter
=
new
Blob
Writ
er
(
1024
);
_stringWriter
=
new
Blob
Build
er
(
1024
);
// Create VirtIdx to Idx map and add entry for empty string
_stringIndexToHeapPositionMap
=
new
int
[
sorted
.
Count
+
1
];
...
...
@@ -420,7 +420,7 @@ public int Compare(KeyValuePair<string, StringIdx> xPair, KeyValuePair<string, S
}
}
public
void
WriteTo
(
Blob
Writ
er
writer
,
out
int
guidHeapStartOffset
)
public
void
WriteTo
(
Blob
Build
er
writer
,
out
int
guidHeapStartOffset
)
{
WriteAligned
(
_stringWriter
,
writer
);
WriteAligned
(
_userStringWriter
,
writer
);
...
...
@@ -431,7 +431,7 @@ public void WriteTo(BlobWriter writer, out int guidHeapStartOffset)
WriteAlignedBlobHeap
(
writer
);
}
private
void
WriteAlignedBlobHeap
(
Blob
Writ
er
writer
)
private
void
WriteAlignedBlobHeap
(
Blob
Build
er
writer
)
{
int
heapStart
=
writer
.
Position
;
...
...
@@ -459,7 +459,7 @@ private void WriteAlignedBlobHeap(BlobWriter writer)
writer
.
WriteBytes
(
0
,
BitArithmeticUtilities
.
Align
(
_blobHeapSize
,
4
)
-
_blobHeapSize
);
}
private
static
void
WriteAligned
(
Blob
Writer
source
,
BlobWrit
er
target
)
private
static
void
WriteAligned
(
Blob
Builder
source
,
BlobBuild
er
target
)
{
int
length
=
source
.
Length
;
source
.
WriteTo
(
target
);
...
...
src/Compilers/Core/Portable/PEWriter/MetadataWriter.PortablePdb.cs
浏览文件 @
8a0a65f0
...
...
@@ -185,7 +185,7 @@ private void SerializeMethodDebugInfo(IMethodBody bodyOpt, int methodRid, int lo
private
BlobIdx
SerializeLocalConstantSignature
(
ILocalDefinition
localConstant
)
{
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
// CustomMod*
SerializeCustomModifiers
(
localConstant
.
CustomModifiers
,
writer
);
...
...
@@ -267,7 +267,7 @@ private enum HasCustomDebugInformationTag
private
const
int
ModuleImportScopeRid
=
1
;
private
void
SerializeImport
(
Blob
Writ
er
writer
,
AssemblyReferenceAlias
alias
)
private
void
SerializeImport
(
Blob
Build
er
writer
,
AssemblyReferenceAlias
alias
)
{
// <import> ::= AliasAssemblyReference <alias> <target-assembly>
writer
.
WriteByte
((
byte
)
ImportDefinitionKind
.
AliasAssemblyReference
);
...
...
@@ -275,7 +275,7 @@ private void SerializeImport(BlobWriter writer, AssemblyReferenceAlias alias)
writer
.
WriteCompressedInteger
((
uint
)
GetOrAddAssemblyRefIndex
(
alias
.
Assembly
));
}
private
void
SerializeImport
(
Blob
Writ
er
writer
,
UsedNamespaceOrType
import
)
private
void
SerializeImport
(
Blob
Build
er
writer
,
UsedNamespaceOrType
import
)
{
if
(
import
.
TargetXmlNamespaceOpt
!=
null
)
{
...
...
@@ -358,7 +358,7 @@ private void SerializeImport(BlobWriter writer, UsedNamespaceOrType import)
private
void
DefineModuleImportScope
()
{
// module-level import scope:
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
SerializeModuleDefaultNamespace
();
...
...
@@ -406,7 +406,7 @@ private int GetImportScopeIndex(IImportScope scope, Dictionary<IImportScope, int
private
BlobIdx
SerializeImportsBlob
(
IImportScope
scope
)
{
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
foreach
(
UsedNamespaceOrType
import
in
scope
.
GetUsedNamespaces
())
{
...
...
@@ -510,7 +510,7 @@ private void SerializeAsyncMethodSteppingInfo(AsyncMethodBodyDebugInfo asyncInfo
Debug
.
Assert
(
asyncInfo
.
ResumeOffsets
.
Length
==
asyncInfo
.
YieldOffsets
.
Length
);
Debug
.
Assert
(
asyncInfo
.
CatchHandlerOffset
>=
-
1
);
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
writer
.
WriteUInt32
((
uint
)((
long
)
asyncInfo
.
CatchHandlerOffset
+
1
));
...
...
@@ -537,7 +537,7 @@ private void SerializeStateMachineLocalScopes(IMethodBody methodBody, int method
return
;
}
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
foreach
(
var
scope
in
scopes
)
{
...
...
@@ -564,7 +564,7 @@ private BlobIdx SerializeSequencePoints(int localSignatureRowId, ImmutableArray<
return
default
(
BlobIdx
);
}
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
int
previousNonHiddenStartLine
=
-
1
;
int
previousNonHiddenStartColumn
=
-
1
;
...
...
@@ -625,7 +625,7 @@ private BlobIdx SerializeSequencePoints(int localSignatureRowId, ImmutableArray<
return
_debugHeapsOpt
.
GetBlobIndex
(
writer
);
}
private
void
SerializeDeltaLinesAndColumns
(
Blob
Writ
er
writer
,
SequencePoint
sequencePoint
)
private
void
SerializeDeltaLinesAndColumns
(
Blob
Build
er
writer
,
SequencePoint
sequencePoint
)
{
int
deltaLines
=
sequencePoint
.
EndLine
-
sequencePoint
.
StartLine
;
int
deltaColumns
=
sequencePoint
.
EndColumn
-
sequencePoint
.
StartColumn
;
...
...
@@ -677,7 +677,7 @@ private BlobIdx SerializeDocumentName(string name)
{
Debug
.
Assert
(
name
!=
null
);
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
int
c1
=
Count
(
name
,
Separator1
[
0
]);
int
c2
=
Count
(
name
,
Separator2
[
0
]);
...
...
@@ -719,7 +719,7 @@ private void SerializeEncMethodDebugInformation(IMethodBody methodBody, int meth
if
(!
encInfo
.
LocalSlots
.
IsDefaultOrEmpty
)
{
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
encInfo
.
SerializeLocalSlots
(
writer
);
...
...
@@ -733,7 +733,7 @@ private void SerializeEncMethodDebugInformation(IMethodBody methodBody, int meth
if
(!
encInfo
.
Lambdas
.
IsDefaultOrEmpty
)
{
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
encInfo
.
SerializeLambdaMap
(
writer
);
...
...
@@ -750,7 +750,7 @@ private void SerializeEncMethodDebugInformation(IMethodBody methodBody, int meth
#
region
Table
Serialization
private
void
SerializeDocumentTable
(
Blob
Writ
er
writer
,
MetadataSizes
metadataSizes
)
private
void
SerializeDocumentTable
(
Blob
Build
er
writer
,
MetadataSizes
metadataSizes
)
{
foreach
(
var
row
in
_documentTable
)
{
...
...
@@ -761,7 +761,7 @@ private void SerializeDocumentTable(BlobWriter writer, MetadataSizes metadataSiz
}
}
private
void
SerializeMethodBodyTable
(
Blob
Writ
er
writer
,
MetadataSizes
metadataSizes
)
private
void
SerializeMethodBodyTable
(
Blob
Build
er
writer
,
MetadataSizes
metadataSizes
)
{
foreach
(
var
row
in
_methodBodyTable
)
{
...
...
@@ -769,7 +769,7 @@ private void SerializeMethodBodyTable(BlobWriter writer, MetadataSizes metadataS
}
}
private
void
SerializeLocalScopeTable
(
Blob
Writ
er
writer
,
MetadataSizes
metadataSizes
)
private
void
SerializeLocalScopeTable
(
Blob
Build
er
writer
,
MetadataSizes
metadataSizes
)
{
foreach
(
var
row
in
_localScopeTable
)
{
...
...
@@ -782,7 +782,7 @@ private void SerializeLocalScopeTable(BlobWriter writer, MetadataSizes metadataS
}
}
private
void
SerializeLocalVariableTable
(
Blob
Writ
er
writer
,
MetadataSizes
metadataSizes
)
private
void
SerializeLocalVariableTable
(
Blob
Build
er
writer
,
MetadataSizes
metadataSizes
)
{
foreach
(
var
row
in
_localVariableTable
)
{
...
...
@@ -792,7 +792,7 @@ private void SerializeLocalVariableTable(BlobWriter writer, MetadataSizes metada
}
}
private
void
SerializeLocalConstantTable
(
Blob
Writ
er
writer
,
MetadataSizes
metadataSizes
)
private
void
SerializeLocalConstantTable
(
Blob
Build
er
writer
,
MetadataSizes
metadataSizes
)
{
foreach
(
var
row
in
_localConstantTable
)
{
...
...
@@ -801,7 +801,7 @@ private void SerializeLocalConstantTable(BlobWriter writer, MetadataSizes metada
}
}
private
void
SerializeImportScopeTable
(
Blob
Writ
er
writer
,
MetadataSizes
metadataSizes
)
private
void
SerializeImportScopeTable
(
Blob
Build
er
writer
,
MetadataSizes
metadataSizes
)
{
foreach
(
var
row
in
_importScopeTable
)
{
...
...
@@ -810,7 +810,7 @@ private void SerializeImportScopeTable(BlobWriter writer, MetadataSizes metadata
}
}
private
void
SerializeStateMachineMethodTable
(
Blob
Writ
er
writer
,
MetadataSizes
metadataSizes
)
private
void
SerializeStateMachineMethodTable
(
Blob
Build
er
writer
,
MetadataSizes
metadataSizes
)
{
foreach
(
var
row
in
_stateMachineMethodTable
)
{
...
...
@@ -819,7 +819,7 @@ private void SerializeStateMachineMethodTable(BlobWriter writer, MetadataSizes m
}
}
private
void
SerializeCustomDebugInformationTable
(
Blob
Writ
er
writer
,
MetadataSizes
metadataSizes
)
private
void
SerializeCustomDebugInformationTable
(
Blob
Build
er
writer
,
MetadataSizes
metadataSizes
)
{
// sort by Parent, Kind
_customDebugInformationTable
.
Sort
(
CustomDebugInformationRowComparer
.
Instance
);
...
...
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
浏览文件 @
8a0a65f0
此差异已折叠。
点击以展开。
src/Compilers/Core/Portable/PEWriter/PeWriter.cs
浏览文件 @
8a0a65f0
...
...
@@ -39,7 +39,7 @@ internal sealed class PeWriter
private
readonly
IEnumerable
<
IWin32Resource
>
_nativeResourcesOpt
;
private
readonly
ResourceSection
_nativeResourceSectionOpt
;
private
readonly
Blob
Writer
_win32ResourceWriter
=
new
BlobWrit
er
(
1024
);
private
readonly
Blob
Builder
_win32ResourceWriter
=
new
BlobBuild
er
(
1024
);
private
PeWriter
(
ModulePropertiesForSerialization
properties
,
...
...
@@ -87,12 +87,12 @@ internal sealed class PeWriter
private
bool
WritePeToStream
(
MetadataWriter
mdWriter
,
Func
<
Stream
>
getPeStream
,
Func
<
Stream
>
getPortablePdbStreamOpt
,
PdbWriter
nativePdbWriterOpt
)
{
// TODO: we can precalculate the exact size of IL stream
var
ilWriter
=
new
Blob
Writ
er
(
32
*
1024
);
var
metadataWriter
=
new
Blob
Writ
er
(
16
*
1024
);
var
mappedFieldDataWriter
=
new
Blob
Writ
er
();
var
managedResourceWriter
=
new
Blob
Writ
er
(
1024
);
var
ilWriter
=
new
Blob
Build
er
(
32
*
1024
);
var
metadataWriter
=
new
Blob
Build
er
(
16
*
1024
);
var
mappedFieldDataWriter
=
new
Blob
Build
er
();
var
managedResourceWriter
=
new
Blob
Build
er
(
1024
);
var
debugMetadataWriterOpt
=
(
getPortablePdbStreamOpt
!=
null
)
?
new
Blob
Writ
er
(
16
*
1024
)
:
null
;
var
debugMetadataWriterOpt
=
(
getPortablePdbStreamOpt
!=
null
)
?
new
Blob
Build
er
(
16
*
1024
)
:
null
;
nativePdbWriterOpt
?.
SetMetadataEmitter
(
mdWriter
);
...
...
@@ -824,7 +824,7 @@ private void SerializeWin32Resources(IEnumerable<IWin32Resource> theResources, i
languageDirectory
.
Entries
.
Add
(
r
);
}
var
dataWriter
=
Blob
Writ
er
.
GetInstance
();
var
dataWriter
=
Blob
Build
er
.
GetInstance
();
//'dataWriter' is where opaque resource data goes as well as strings that are used as type or name identifiers
this
.
WriteDirectory
(
typeDirectory
,
_win32ResourceWriter
,
0
,
0
,
sizeOfDirectoryTree
,
resourcesRva
,
dataWriter
);
...
...
@@ -838,7 +838,7 @@ private void SerializeWin32Resources(IEnumerable<IWin32Resource> theResources, i
dataWriter
.
Free
();
}
private
void
WriteDirectory
(
Directory
directory
,
Blob
Writer
writer
,
uint
offset
,
uint
level
,
uint
sizeOfDirectoryTree
,
int
virtualAddressBase
,
BlobWrit
er
dataWriter
)
private
void
WriteDirectory
(
Directory
directory
,
Blob
Builder
writer
,
uint
offset
,
uint
level
,
uint
sizeOfDirectoryTree
,
int
virtualAddressBase
,
BlobBuild
er
dataWriter
)
{
writer
.
WriteUInt32
(
0
);
// Characteristics
writer
.
WriteUInt32
(
0
);
// Timestamp
...
...
@@ -1009,7 +1009,7 @@ private void SerializeWin32Resources(ResourceSection resourceSections, int resou
private
void
WriteHeaders
(
Stream
peStream
,
NtHeader
ntHeader
,
CoffHeader
coffHeader
,
List
<
SectionHeader
>
sectionHeaders
,
out
long
ntHeaderTimestampPosition
)
{
var
writer
=
new
Blob
Writ
er
(
1024
);
var
writer
=
new
Blob
Build
er
(
1024
);
// MS-DOS stub (128 bytes)
writer
.
WriteBytes
(
s_dosHeader
);
...
...
@@ -1129,7 +1129,7 @@ private void WriteHeaders(Stream peStream, NtHeader ntHeader, CoffHeader coffHea
writer
.
WriteTo
(
peStream
);
}
private
static
void
WriteSectionHeader
(
SectionHeader
sectionHeader
,
Blob
Writ
er
writer
)
private
static
void
WriteSectionHeader
(
SectionHeader
sectionHeader
,
Blob
Build
er
writer
)
{
if
(
sectionHeader
.
VirtualSize
==
0
)
{
...
...
@@ -1165,10 +1165,10 @@ private static void WriteSectionHeader(SectionHeader sectionHeader, BlobWriter w
int
importTableRva
,
int
importAddressTableRva
,
int
entryPointToken
,
Blob
Writ
er
metadataWriter
,
Blob
Writ
er
ilWriter
,
Blob
Writ
er
mappedFieldDataWriter
,
Blob
Writ
er
managedResourceWriter
,
Blob
Build
er
metadataWriter
,
Blob
Build
er
ilWriter
,
Blob
Build
er
mappedFieldDataWriter
,
Blob
Build
er
managedResourceWriter
,
MetadataSizes
metadataSizes
,
ContentId
nativePdbContentId
,
ContentId
portablePdbContentId
,
...
...
@@ -1227,7 +1227,7 @@ private static void WriteSectionHeader(SectionHeader sectionHeader, BlobWriter w
private
void
WriteImportAddressTable
(
Stream
peStream
,
int
importTableRva
)
{
var
writer
=
new
Blob
Writ
er
(
SizeOfImportAddressTable
);
var
writer
=
new
Blob
Build
er
(
SizeOfImportAddressTable
);
int
ilRVA
=
importTableRva
+
40
;
int
hintRva
=
ilRVA
+
(
_is32bit
?
12
:
16
);
...
...
@@ -1249,7 +1249,7 @@ private void WriteImportAddressTable(Stream peStream, int importTableRva)
private
void
WriteImportTable
(
Stream
peStream
,
int
importTableRva
,
int
importAddressTableRva
)
{
var
writer
=
new
Blob
Writ
er
(
SizeOfImportTable
);
var
writer
=
new
Blob
Build
er
(
SizeOfImportTable
);
int
ilRVA
=
importTableRva
+
40
;
int
hintRva
=
ilRVA
+
(
_is32bit
?
12
:
16
);
int
nameRva
=
hintRva
+
12
+
2
;
...
...
@@ -1291,7 +1291,7 @@ private void WriteImportTable(Stream peStream, int importTableRva, int importAdd
private
static
void
WriteNameTable
(
Stream
peStream
)
{
var
writer
=
new
Blob
Writ
er
(
SizeOfNameTable
);
var
writer
=
new
Blob
Build
er
(
SizeOfNameTable
);
foreach
(
char
ch
in
CorEntryPointDll
)
{
writer
.
WriteByte
((
byte
)
ch
);
...
...
@@ -1306,7 +1306,7 @@ private static void WriteNameTable(Stream peStream)
private
static
void
WriteCorHeader
(
Stream
peStream
,
CorHeader
corHeader
)
{
var
writer
=
new
Blob
Writ
er
(
CorHeaderSize
);
var
writer
=
new
Blob
Build
er
(
CorHeaderSize
);
writer
.
WriteUInt32
(
CorHeaderSize
);
writer
.
WriteUInt16
(
corHeader
.
MajorRuntimeVersion
);
writer
.
WriteUInt16
(
corHeader
.
MinorRuntimeVersion
);
...
...
@@ -1344,7 +1344,7 @@ private void WriteDebugTable(Stream peStream, SectionHeader textSection, Content
{
Debug
.
Assert
(
nativePdbContentId
.
IsDefault
^
portablePdbContentId
.
IsDefault
);
var
writer
=
new
Blob
Writ
er
();
var
writer
=
new
Blob
Build
er
();
// characteristics:
writer
.
WriteUInt32
(
0
);
...
...
@@ -1397,7 +1397,7 @@ private void WriteDebugTable(Stream peStream, SectionHeader textSection, Content
private
void
WriteRuntimeStartupStub
(
Stream
peStream
,
int
importAddressTableRva
)
{
var
writer
=
new
Blob
Writ
er
(
16
);
var
writer
=
new
Blob
Build
er
(
16
);
// entry point code, consisting of a jump indirect to _CorXXXMain
if
(
_is32bit
)
{
...
...
@@ -1433,7 +1433,7 @@ private void WriteRuntimeStartupStub(Stream peStream, int importAddressTableRva)
private
void
WriteRelocSection
(
Stream
peStream
,
SectionHeader
relocSection
,
int
entryPointAddress
)
{
peStream
.
Position
=
relocSection
.
PointerToRawData
;
var
writer
=
new
Blob
Writ
er
(
relocSection
.
SizeOfRawData
);
var
writer
=
new
Blob
Build
er
(
relocSection
.
SizeOfRawData
);
writer
.
WriteUInt32
((((
uint
)
entryPointAddress
+
2
)
/
0x1000
)
*
0x1000
);
writer
.
WriteUInt32
(
_properties
.
Requires64bits
&&
!
_properties
.
RequiresAmdInstructionSet
?
14u
:
12u
);
uint
offsetWithinPage
=
((
uint
)
entryPointAddress
+
2
)
%
0x1000
;
...
...
src/Compilers/VisualBasic/Portable/CodeGen/EmitArrayInitializer.vb
浏览文件 @
8a0a65f0
...
...
@@ -264,14 +264,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGen
' the initial size is a guess.
' there is no point to be precise here as MemoryStream always has N + 1 storage
' and will need to be trimmed regardless
Dim
writer
As
New
Cci
.
Blob
Writ
er
(
initializers
.
Length
*
4
)
Dim
writer
As
New
Cci
.
Blob
Build
er
(
initializers
.
Length
*
4
)
SerializeArrayRecursive
(
writer
,
initializers
)
Return
writer
.
ToImmutableArray
()
End
Function
Private
Sub
SerializeArrayRecursive
(
bw
As
Cci
.
Blob
Writ
er
,
inits
As
ImmutableArray
(
Of
BoundExpression
))
Private
Sub
SerializeArrayRecursive
(
bw
As
Cci
.
Blob
Build
er
,
inits
As
ImmutableArray
(
Of
BoundExpression
))
If
inits
.
Length
<>
0
Then
If
inits
(
0
).
Kind
=
BoundKind
.
ArrayInitialization
Then
For
Each
init
In
inits
...
...
src/Test/Utilities/ILBuilderVisualizer.cs
浏览文件 @
8a0a65f0
...
...
@@ -187,10 +187,10 @@ private static void DumpBlockIL(ILBuilder.BasicBlock block, StringBuilder sb)
private
static
void
DumpBasicBlockIL
(
ILBuilder
.
BasicBlock
block
,
StringBuilder
sb
)
{
var
instrCnt
=
(
int
)
block
.
RegularInstructionsLength
;
var
instrCnt
=
block
.
RegularInstructionsLength
;
if
(
instrCnt
!=
0
)
{
byte
[]
il
=
block
.
RegularInstructions
.
Buffer
;
byte
[]
il
=
block
.
RegularInstructions
.
ToArray
()
;
new
ILBuilderVisualizer
(
block
.
builder
.
module
).
DumpILBlock
(
il
,
instrCnt
,
sb
,
SpecializedCollections
.
EmptyArray
<
ILVisualizer
.
HandlerSpan
>(),
block
.
Start
);
}
...
...
@@ -219,8 +219,8 @@ private static void DumpBasicBlockIL(ILBuilder.BasicBlock block, StringBuilder s
private
static
void
DumpSwitchBlockIL
(
ILBuilder
.
SwitchBlock
block
,
StringBuilder
sb
)
{
byte
[]
il
=
block
.
RegularInstructions
.
Buffer
;
new
ILBuilderVisualizer
(
block
.
builder
.
module
).
DumpILBlock
(
il
,
(
int
)
block
.
RegularInstructionsLength
,
sb
,
SpecializedCollections
.
EmptyArray
<
ILVisualizer
.
HandlerSpan
>(),
block
.
Start
);
byte
[]
il
=
block
.
RegularInstructions
.
ToArray
()
;
new
ILBuilderVisualizer
(
block
.
builder
.
module
).
DumpILBlock
(
il
,
il
.
Length
,
sb
,
SpecializedCollections
.
EmptyArray
<
HandlerSpan
>(),
block
.
Start
);
// switch (N, t1, t2... tN)
// IL ==> ILOpCode.Switch < unsigned int32 > < int32 >... < int32 >
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录