Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
7ba371c7
R
runtime
项目概览
dotNET Platform
/
runtime
11 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7ba371c7
编写于
11月 01, 2022
作者:
E
Egor Bogatov
提交者:
GitHub
11月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Run dotnet-format for ThunkGenerator (#77715)
上级
705babd9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
49 deletion
+49
-49
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs
...on/JitInterface/ThunkGenerator/InstructionSetGenerator.cs
+15
-15
src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs
...reclr/tools/Common/JitInterface/ThunkGenerator/Program.cs
+34
-34
未找到文件。
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs
浏览文件 @
7ba371c7
...
...
@@ -3,17 +3,17 @@
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.IO
;
using
System.Diagnostics
;
namespace
Thunkerator
{
public
class
InstructionSetGenerator
{
class
InstructionSetInfo
sealed
class
InstructionSetInfo
{
public
string
Architecture
{
get
;
}
public
string
ManagedName
{
get
;
}
...
...
@@ -58,9 +58,9 @@ public string PublicName
}
}
record
InstructionSetGroup
(
string
Names
,
string
Archs
,
string
Sets
);
sealed
record
InstructionSetGroup
(
string
Names
,
string
Archs
,
string
Sets
);
class
InstructionSetImplication
sealed
class
InstructionSetImplication
{
public
string
Architecture
{
get
;
}
public
string
JitName
{
get
;
}
...
...
@@ -85,13 +85,13 @@ public InstructionSetImplication(string architecture, InstructionSetImplication
List
<
InstructionSetImplication
>
_implications
=
new
List
<
InstructionSetImplication
>();
List
<
InstructionSetGroup
>
_instructionSetsGroups
=
new
List
<
InstructionSetGroup
>();
Dictionary
<
string
,
HashSet
<
string
>>
_64bitVariants
=
new
Dictionary
<
string
,
HashSet
<
string
>>();
SortedDictionary
<
string
,
int
>
_r2rNamesByName
=
new
SortedDictionary
<
string
,
int
>();
SortedDictionary
<
int
,
string
>
_r2rNamesByNumber
=
new
SortedDictionary
<
int
,
string
>();
SortedDictionary
<
string
,
int
>
_r2rNamesByName
=
new
SortedDictionary
<
string
,
int
>();
SortedDictionary
<
int
,
string
>
_r2rNamesByNumber
=
new
SortedDictionary
<
int
,
string
>();
SortedSet
<
string
>
_architectures
=
new
SortedSet
<
string
>();
Dictionary
<
string
,
List
<
string
>>
_architectureJitNames
=
new
Dictionary
<
string
,
List
<
string
>>();
Dictionary
<
string
,
List
<
string
>>
_architectureVectorInstructionSetJitNames
=
new
Dictionary
<
string
,
List
<
string
>>();
Dictionary
<
string
,
List
<
string
>>
_architectureJitNames
=
new
Dictionary
<
string
,
List
<
string
>>();
Dictionary
<
string
,
List
<
string
>>
_architectureVectorInstructionSetJitNames
=
new
Dictionary
<
string
,
List
<
string
>>();
HashSet
<
string
>
_64BitArchitectures
=
new
HashSet
<
string
>();
Dictionary
<
string
,
string
>
_64BitVariantArchitectureJitNameSuffix
=
new
Dictionary
<
string
,
string
>();
Dictionary
<
string
,
string
>
_64BitVariantArchitectureJitNameSuffix
=
new
Dictionary
<
string
,
string
>();
// This represents the number of flags fields we currently track
const
int
FlagsFieldCount
=
1
;
...
...
@@ -112,7 +112,7 @@ void ValidateArchitectureEncountered(string arch)
throw
new
Exception
(
"Architecture not defined"
);
}
private
string
ArchToIfDefArch
(
string
arch
)
private
st
atic
st
ring
ArchToIfDefArch
(
string
arch
)
{
if
(
arch
==
"X64"
)
return
"AMD64"
;
...
...
@@ -147,7 +147,7 @@ public bool ParseInput(TextReader tr)
{
command
[
i
]
=
command
[
i
].
Trim
();
}
switch
(
command
[
0
])
switch
(
command
[
0
])
{
case
"definearch"
:
if
(
command
.
Length
!=
4
)
...
...
@@ -168,7 +168,7 @@ public bool ParseInput(TextReader tr)
throw
new
Exception
(
"Incorrect number of args for instructionset"
);
ValidateArchitectureEncountered
(
command
[
1
]);
_architectureJitNames
[
command
[
1
]].
Add
(
command
[
5
]);
_instructionSets
.
Add
(
new
InstructionSetInfo
(
command
[
1
],
command
[
2
],
command
[
3
],
command
[
4
],
command
[
5
],
command
[
6
]));
_instructionSets
.
Add
(
new
InstructionSetInfo
(
command
[
1
],
command
[
2
],
command
[
3
],
command
[
4
],
command
[
5
],
command
[
6
]));
break
;
case
"vectorinstructionset"
:
if
(
command
.
Length
!=
3
)
...
...
@@ -187,7 +187,7 @@ public bool ParseInput(TextReader tr)
if
(
command
.
Length
!=
4
)
throw
new
Exception
(
"Incorrect number of args for instructionset"
);
ValidateArchitectureEncountered
(
command
[
1
]);
_implications
.
Add
(
new
InstructionSetImplication
(
command
[
1
],
command
[
2
],
command
[
3
]));
_implications
.
Add
(
new
InstructionSetImplication
(
command
[
1
],
command
[
2
],
command
[
3
]));
break
;
case
"instructionsetgroup"
:
if
(
command
.
Length
!=
4
)
...
...
@@ -1026,7 +1026,7 @@ void Set64BitInstructionSetVariants()
string
r2rEnumerationValue
;
if
(
String
.
IsNullOrEmpty
(
instructionSet
.
R2rName
))
continue
;
r2rEnumerationValue
=
$"READYTORUN_INSTRUCTION_
{
instructionSet
.
R2rName
}
"
;
tr
.
WriteLine
(
$" case
{
r2rEnumerationValue
}
: return InstructionSet_
{
instructionSet
.
JitName
}
;"
);
...
...
src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs
浏览文件 @
7ba371c7
...
...
@@ -3,11 +3,11 @@
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.IO
;
using
System.Diagnostics
;
namespace
Thunkerator
{
...
...
@@ -34,7 +34,7 @@ public static string Canonicalize(this string current)
}
}
class
TypeReplacement
sealed
class
TypeReplacement
{
public
TypeReplacement
(
string
line
)
{
...
...
@@ -100,7 +100,7 @@ public string UnmanagedTypeName
}
}
class
Parameter
sealed
class
Parameter
{
public
Parameter
(
string
name
,
TypeReplacement
type
)
{
...
...
@@ -114,7 +114,7 @@ public Parameter(string name, TypeReplacement type)
public
readonly
TypeReplacement
Type
;
}
class
FunctionDecl
sealed
class
FunctionDecl
{
public
FunctionDecl
(
string
line
,
Dictionary
<
string
,
TypeReplacement
>
ThunkReturnTypes
,
Dictionary
<
string
,
TypeReplacement
>
ThunkTypes
)
{
...
...
@@ -139,7 +139,7 @@ public FunctionDecl(string line, Dictionary<string, TypeReplacement> ThunkReturn
}
string
parameterList
=
line
.
Substring
(
indexOfOpenParen
+
1
,
indexOfCloseParen
-
indexOfOpenParen
-
1
).
Canonicalize
();
string
[]
parametersString
=
parameterList
.
Length
==
0
?
new
string
[
0
]
:
parameterList
.
Split
(
','
);
string
[]
parametersString
=
parameterList
.
Length
==
0
?
Array
.
Empty
<
string
>()
:
parameterList
.
Split
(
','
);
List
<
Parameter
>
parameters
=
new
List
<
Parameter
>();
foreach
(
string
parameterString
in
parametersString
)
...
...
@@ -161,10 +161,10 @@ public FunctionDecl(string line, Dictionary<string, TypeReplacement> ThunkReturn
public
readonly
string
FunctionName
;
public
readonly
TypeReplacement
ReturnType
;
public
readonly
Parameter
[]
Parameters
;
public
readonly
bool
ManualNativeWrapper
=
false
;
public
readonly
bool
ManualNativeWrapper
;
}
class
Program
static
class
Program
{
enum
ParseMode
{
...
...
@@ -406,13 +406,13 @@ class JitInterfaceWrapper : public ICorJitInfo
"
);
API_Wrapper_Generic_Core
(
tw
,
functionData
,
funcNameFunc
:
(
FunctionDecl
decl
)
=>
$"
{
decl
.
FunctionName
}
"
,
beforeCallFunc
:
(
FunctionDecl
)=>
" CorInfoExceptionClass* pException = nullptr;"
,
afterCallFunc
:
(
FunctionDecl
decl
)
=>
" if (pException != nullptr) throw pException;"
,
wrappedObjectName
:
"_callbacks"
,
useNativeType2
:
false
,
addVirtualPrefix
:
true
,
API_Wrapper_Generic_Core
(
tw
,
functionData
,
funcNameFunc
:
(
FunctionDecl
decl
)
=>
$"
{
decl
.
FunctionName
}
"
,
beforeCallFunc
:
(
FunctionDecl
)
=>
" CorInfoExceptionClass* pException = nullptr;"
,
afterCallFunc
:
(
FunctionDecl
decl
)
=>
" if (pException != nullptr) throw pException;"
,
wrappedObjectName
:
"_callbacks"
,
useNativeType2
:
false
,
addVirtualPrefix
:
true
,
skipManualWrapper
:
true
);
tw
.
WriteLine
(
"};"
);
...
...
@@ -432,7 +432,7 @@ static void WriteAPI_Names(TextWriter tw, IEnumerable<FunctionDecl> functionData
"
);
}
static
void
API_Wrapper_Generic_Core
(
TextWriter
tw
,
IEnumerable
<
FunctionDecl
>
functionData
,
Func
<
FunctionDecl
,
string
>
funcNameFunc
,
Func
<
FunctionDecl
,
string
>
beforeCallFunc
,
Func
<
FunctionDecl
,
string
>
afterCallFunc
,
string
wrappedObjectName
,
bool
useNativeType2
,
bool
addVirtualPrefix
,
bool
skipManualWrapper
)
static
void
API_Wrapper_Generic_Core
(
TextWriter
tw
,
IEnumerable
<
FunctionDecl
>
functionData
,
Func
<
FunctionDecl
,
string
>
funcNameFunc
,
Func
<
FunctionDecl
,
string
>
beforeCallFunc
,
Func
<
FunctionDecl
,
string
>
afterCallFunc
,
string
wrappedObjectName
,
bool
useNativeType2
,
bool
addVirtualPrefix
,
bool
skipManualWrapper
)
{
foreach
(
FunctionDecl
decl
in
functionData
)
{
...
...
@@ -516,35 +516,35 @@ string GetNativeType(TypeReplacement typeReplacement)
}
}
static
void
API_Wrapper_Generic
(
TextWriter
tw
,
IEnumerable
<
FunctionDecl
>
functionData
,
string
header
,
string
footer
,
string
cppType
,
Func
<
FunctionDecl
,
string
>
beforeCallFunc
,
Func
<
FunctionDecl
,
string
>
afterCallFunc
,
string
wrappedObjectName
)
static
void
API_Wrapper_Generic
(
TextWriter
tw
,
IEnumerable
<
FunctionDecl
>
functionData
,
string
header
,
string
footer
,
string
cppType
,
Func
<
FunctionDecl
,
string
>
beforeCallFunc
,
Func
<
FunctionDecl
,
string
>
afterCallFunc
,
string
wrappedObjectName
)
{
WriteAutogeneratedHeader
(
tw
);
tw
.
Write
(
header
);
API_Wrapper_Generic_Core
(
tw
,
functionData
,
funcNameFunc
:
(
FunctionDecl
decl
)
=>
$"
{
cppType
}
::
{
decl
.
FunctionName
}
"
,
beforeCallFunc
:
beforeCallFunc
,
afterCallFunc
:
afterCallFunc
,
wrappedObjectName
:
wrappedObjectName
,
useNativeType2
:
true
,
addVirtualPrefix
:
false
,
skipManualWrapper
:
false
);
API_Wrapper_Generic_Core
(
tw
,
functionData
,
funcNameFunc
:
(
FunctionDecl
decl
)
=>
$"
{
cppType
}
::
{
decl
.
FunctionName
}
"
,
beforeCallFunc
:
beforeCallFunc
,
afterCallFunc
:
afterCallFunc
,
wrappedObjectName
:
wrappedObjectName
,
useNativeType2
:
true
,
addVirtualPrefix
:
false
,
skipManualWrapper
:
false
);
tw
.
Write
(
footer
);
}
static
void
API_Wrapper
(
TextWriter
tw
,
IEnumerable
<
FunctionDecl
>
functionData
)
{
API_Wrapper_Generic
(
tw
,
functionData
,
header
:
@"
API_Wrapper_Generic
(
tw
,
functionData
,
header
:
@"
#define API_ENTER(name) wrapComp->CLR_API_Enter(API_##name);
#define API_LEAVE(name) wrapComp->CLR_API_Leave(API_##name);
/**********************************************************************************/
// clang-format off
/**********************************************************************************/
"
,
"
,
footer
:
@"
/**********************************************************************************/
// clang-format on
/**********************************************************************************/
"
,
cppType
:
"WrapICorJitInfo"
,
beforeCallFunc
:
(
FunctionDecl
decl
)=>
$" API_ENTER(
{
decl
.
FunctionName
}
);"
,
afterCallFunc
:
(
FunctionDecl
decl
)=>
$" API_LEAVE(
{
decl
.
FunctionName
}
);"
,
beforeCallFunc
:
(
FunctionDecl
decl
)
=>
$" API_ENTER(
{
decl
.
FunctionName
}
);"
,
afterCallFunc
:
(
FunctionDecl
decl
)
=>
$" API_LEAVE(
{
decl
.
FunctionName
}
);"
,
wrappedObjectName
:
"wrapHnd"
);
}
...
...
@@ -571,7 +571,7 @@ static void SPMI_ICorJitInfoImpl(TextWriter tw, IEnumerable<FunctionDecl> functi
foreach
(
FunctionDecl
decl
in
functionData
)
{
tw
.
Write
(
$"
{
Environment
.
NewLine
}{
decl
.
ReturnType
.
NativeTypeName2
}
{
decl
.
FunctionName
}
("
);
tw
.
Write
(
$"
{
Environment
.
NewLine
}{
decl
.
ReturnType
.
NativeTypeName2
}
{
decl
.
FunctionName
}
("
);
bool
isFirst
=
true
;
foreach
(
Parameter
param
in
decl
.
Parameters
)
{
...
...
@@ -597,37 +597,37 @@ static void SPMI_ICorJitInfoImpl(TextWriter tw, IEnumerable<FunctionDecl> functi
static
void
SPMI_ShimCounter_ICorJitInfo
(
TextWriter
tw
,
IEnumerable
<
FunctionDecl
>
functionData
)
{
API_Wrapper_Generic
(
tw
,
functionData
,
header
:
@"
API_Wrapper_Generic
(
tw
,
functionData
,
header
:
@"
#include ""standardpch.h""
#include ""icorjitinfo.h""
#include ""superpmi-shim-counter.h""
#include ""icorjitcompiler.h""
#include ""spmiutil.h""
"
,
"
,
footer
:
Environment
.
NewLine
,
cppType
:
"interceptor_ICJI"
,
beforeCallFunc
:
(
FunctionDecl
decl
)=>
$" mcs->AddCall(\"
{
decl
.
FunctionName
}
\");"
,
afterCallFunc
:
(
FunctionDecl
decl
)=>
null
,
beforeCallFunc
:
(
FunctionDecl
decl
)
=>
$" mcs->AddCall(\"
{
decl
.
FunctionName
}
\");"
,
afterCallFunc
:
(
FunctionDecl
decl
)
=>
null
,
wrappedObjectName
:
"original_ICorJitInfo"
);
}
static
void
SPMI_ShimSimple_ICorJitInfo
(
TextWriter
tw
,
IEnumerable
<
FunctionDecl
>
functionData
)
{
API_Wrapper_Generic
(
tw
,
functionData
,
header
:
@"
API_Wrapper_Generic
(
tw
,
functionData
,
header
:
@"
#include ""standardpch.h""
#include ""icorjitinfo.h""
#include ""superpmi-shim-simple.h""
#include ""icorjitcompiler.h""
#include ""spmiutil.h""
"
,
"
,
footer
:
Environment
.
NewLine
,
cppType
:
"interceptor_ICJI"
,
beforeCallFunc
:
(
FunctionDecl
decl
)=>
null
,
afterCallFunc
:
(
FunctionDecl
decl
)=>
null
,
beforeCallFunc
:
(
FunctionDecl
decl
)
=>
null
,
afterCallFunc
:
(
FunctionDecl
decl
)
=>
null
,
wrappedObjectName
:
"original_ICorJitInfo"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录