Skip to content

Commit 3562e2e

Browse files
committed
[JSC] Upgrade capstone
https://bugs.webkit.org/show_bug.cgi?id=292850 rdar://151126777 Reviewed by Sosuke Suzuki. Upgrade to 5.0.6. Dropping MIPS, and adding ARM64 and RISCV. Canonical link: https://commits.webkit.org/294779@main
1 parent cd1cf3c commit 3562e2e

343 files changed

Lines changed: 1073924 additions & 70655 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Source/JavaScriptCore/disassembler/CapstoneDisassembler.cpp‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ bool tryToDisassemble(const CodePtr<DisassemblyPtrTag>& codePtr, size_t size, vo
4141
csh handle;
4242
cs_insn* instructions;
4343

44-
#if CPU(X86_64)
45-
if (cs_open(CS_ARCH_X86, CS_MODE_64, &handle) != CS_ERR_OK)
46-
return false;
47-
#elif CPU(ARM_THUMB2)
44+
#if CPU(ARM_THUMB2)
4845
if (cs_open(CS_ARCH_ARM, CS_MODE_THUMB, &handle) != CS_ERR_OK)
4946
return false;
5047
if (cs_option(handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_NOREGNAME) != CS_ERR_OK)
@@ -56,13 +53,6 @@ bool tryToDisassemble(const CodePtr<DisassemblyPtrTag>& codePtr, size_t size, vo
5653
return false;
5754
#endif
5855

59-
#if CPU(X86_64)
60-
if (cs_option(handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT) != CS_ERR_OK) {
61-
cs_close(&handle);
62-
return false;
63-
}
64-
#endif
65-
6656
size_t count = cs_disasm(handle, codePtr.dataLocation<unsigned char*>(), size, codePtr.dataLocation<uintptr_t>(), 0, &instructions);
6757
if (count > 0) {
6858
for (size_t i = 0; i < count; ++i) {

‎Source/ThirdParty/capstone/CMakeLists.txt‎

Lines changed: 93 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ add_definitions(-DCAPSTONE_USE_SYS_DYN_MEM)
1616
## sources
1717
set(SOURCES_ENGINE
1818
Source/cs.c
19+
Source/Mapping.c
1920
Source/MCInst.c
2021
Source/MCInstrDesc.c
2122
Source/MCRegisterInfo.c
2223
Source/SStream.c
2324
Source/utils.c
2425
)
2526
set(HEADERS_ENGINE
27+
Source/cs_simple_types.h
2628
Source/cs_priv.h
2729
Source/LEB128.h
30+
Source/Mapping.h
2831
Source/MathExtras.h
2932
Source/MCDisassembler.h
3033
Source/MCFixedLenDisassembler.h
@@ -33,13 +36,14 @@ set(HEADERS_ENGINE
3336
Source/MCRegisterInfo.h
3437
Source/SStream.h
3538
Source/utils.h
36-
)
39+
)
3740

3841
set(HEADERS_COMMON
3942
Source/include/capstone/arm64.h
4043
Source/include/capstone/arm.h
4144
Source/include/capstone/capstone.h
4245
Source/include/capstone/evm.h
46+
Source/include/capstone/wasm.h
4347
Source/include/capstone/mips.h
4448
Source/include/capstone/ppc.h
4549
Source/include/capstone/x86.h
@@ -50,8 +54,31 @@ set(HEADERS_COMMON
5054
Source/include/capstone/tms320c64x.h
5155
Source/include/capstone/m680x.h
5256
Source/include/capstone/mos65xx.h
57+
Source/include/capstone/bpf.h
58+
Source/include/capstone/riscv.h
59+
Source/include/capstone/sh.h
60+
Source/include/capstone/tricore.h
5361
Source/include/capstone/platform.h
54-
)
62+
63+
Source/arch/AArch64/AArch64Module.h
64+
Source/arch/ARM/ARMModule.h
65+
Source/arch/EVM/EVMModule.h
66+
Source/arch/WASM/WASMModule.h
67+
Source/arch/M680X/M680XModule.h
68+
Source/arch/M68K/M68KModule.h
69+
Source/arch/Mips/MipsModule.h
70+
Source/arch/PowerPC/PPCModule.h
71+
Source/arch/Sparc/SparcModule.h
72+
Source/arch/SystemZ/SystemZModule.h
73+
Source/arch/TMS320C64x/TMS320C64xModule.h
74+
Source/arch/X86/X86Module.h
75+
Source/arch/XCore/XCoreModule.h
76+
Source/arch/RISCV/RISCVModule.h
77+
Source/arch/MOS65XX/MOS65XXModule.h
78+
Source/arch/BPF/BPFModule.h
79+
Source/arch/SH/SHModule.h
80+
Source/arch/TriCore/TriCoreModule.h
81+
)
5582

5683
## architecture support
5784
if (WTF_CPU_ARM)
@@ -66,72 +93,89 @@ if (WTF_CPU_ARM)
6693
Source/arch/ARM/ARMAddressingModes.h
6794
Source/arch/ARM/ARMBaseInfo.h
6895
Source/arch/ARM/ARMDisassembler.h
69-
Source/arch/ARM/ARMGenAsmWriter.inc
70-
Source/arch/ARM/ARMGenDisassemblerTables.inc
71-
Source/arch/ARM/ARMGenInstrInfo.inc
72-
Source/arch/ARM/ARMGenRegisterInfo.inc
73-
Source/arch/ARM/ARMGenSubtargetInfo.inc
7496
Source/arch/ARM/ARMInstPrinter.h
7597
Source/arch/ARM/ARMMapping.h
76-
Source/arch/ARM/ARMMappingInsn.inc
77-
Source/arch/ARM/ARMMappingInsnOp.inc
78-
)
79-
set(HEADERS_ARM
80-
Source/arch/ARM/ARMAddressingModes.h
81-
Source/arch/ARM/ARMBaseInfo.h
82-
Source/arch/ARM/ARMDisassembler.h
8398
Source/arch/ARM/ARMGenAsmWriter.inc
8499
Source/arch/ARM/ARMGenDisassemblerTables.inc
85100
Source/arch/ARM/ARMGenInstrInfo.inc
86101
Source/arch/ARM/ARMGenRegisterInfo.inc
87102
Source/arch/ARM/ARMGenSubtargetInfo.inc
88-
Source/arch/ARM/ARMInstPrinter.h
89-
Source/arch/ARM/ARMMapping.h
90-
)
103+
Source/arch/ARM/ARMMappingInsn.inc
104+
Source/arch/ARM/ARMMappingInsnOp.inc
105+
Source/arch/ARM/ARMGenRegisterName.inc
106+
Source/arch/ARM/ARMGenRegisterName_digit.inc
107+
Source/arch/ARM/ARMGenSystemRegister.inc
108+
Source/arch/ARM/ARMMappingInsnName.inc
109+
)
91110
endif ()
92111

93-
if (WTF_CPU_MIPS)
94-
add_definitions(-DCAPSTONE_HAS_MIPS)
95-
set(SOURCES_MIPS
96-
Source/arch/Mips/MipsDisassembler.c
97-
Source/arch/Mips/MipsInstPrinter.c
98-
Source/arch/Mips/MipsMapping.c
99-
Source/arch/Mips/MipsModule.c
112+
if(WTF_CPU_ARM64)
113+
add_definitions(-DCAPSTONE_HAS_ARM64)
114+
set(SOURCES_ARM64
115+
Source/arch/AArch64/AArch64BaseInfo.c
116+
Source/arch/AArch64/AArch64Disassembler.c
117+
Source/arch/AArch64/AArch64InstPrinter.c
118+
Source/arch/AArch64/AArch64Mapping.c
119+
Source/arch/AArch64/AArch64Module.c
100120
)
101-
set(HEADERS_MIPS
102-
Source/arch/Mips/MipsDisassembler.h
103-
Source/arch/Mips/MipsGenAsmWriter.inc
104-
Source/arch/Mips/MipsGenDisassemblerTables.inc
105-
Source/arch/Mips/MipsGenInstrInfo.inc
106-
Source/arch/Mips/MipsGenRegisterInfo.inc
107-
Source/arch/Mips/MipsGenSubtargetInfo.inc
108-
Source/arch/Mips/MipsInstPrinter.h
109-
Source/arch/Mips/MipsMapping.h
110-
Source/arch/Mips/MipsMappingInsn.inc
111-
)
112-
set(HEADERS_MIPS
113-
Source/arch/Mips/MipsDisassembler.h
114-
Source/arch/Mips/MipsGenAsmWriter.inc
115-
Source/arch/Mips/MipsGenDisassemblerTables.inc
116-
Source/arch/Mips/MipsGenInstrInfo.inc
117-
Source/arch/Mips/MipsGenRegisterInfo.inc
118-
Source/arch/Mips/MipsGenSubtargetInfo.inc
119-
Source/arch/Mips/MipsInstPrinter.h
120-
Source/arch/Mips/MipsMapping.h
121-
)
122-
endif ()
121+
set(HEADERS_ARM64
122+
Source/arch/AArch64/AArch64AddressingModes.h
123+
Source/arch/AArch64/AArch64BaseInfo.h
124+
Source/arch/AArch64/AArch64Disassembler.h
125+
Source/arch/AArch64/AArch64InstPrinter.h
126+
Source/arch/AArch64/AArch64Mapping.h
127+
Source/arch/AArch64/AArch64GenAsmWriter.inc
128+
Source/arch/AArch64/AArch64GenDisassemblerTables.inc
129+
Source/arch/AArch64/AArch64GenInstrInfo.inc
130+
Source/arch/AArch64/AArch64GenRegisterInfo.inc
131+
Source/arch/AArch64/AArch64GenRegisterName.inc
132+
Source/arch/AArch64/AArch64GenRegisterV.inc
133+
Source/arch/AArch64/AArch64GenSubtargetInfo.inc
134+
Source/arch/AArch64/AArch64GenSystemOperands.inc
135+
Source/arch/AArch64/AArch64GenSystemOperands_enum.inc
136+
Source/arch/AArch64/AArch64MappingInsn.inc
137+
Source/arch/AArch64/AArch64MappingInsnName.inc
138+
Source/arch/AArch64/AArch64MappingInsnOp.inc
139+
)
140+
endif()
141+
142+
if(WTF_CPU_RISCV)
143+
add_definitions(-DCAPSTONE_HAS_RISCV)
144+
set(SOURCES_RISCV
145+
Source/arch/RISCV/RISCVDisassembler.c
146+
Source/arch/RISCV/RISCVInstPrinter.c
147+
Source/arch/RISCV/RISCVMapping.c
148+
Source/arch/RISCV/RISCVModule.c
149+
)
150+
set(HEADERS_RISCV
151+
Source/arch/RISCV/RISCVBaseInfo.h
152+
Source/arch/RISCV/RISCVDisassembler.h
153+
Source/arch/RISCV/RISCVInstPrinter.h
154+
Source/arch/RISCV/RISCVMapping.h
155+
Source/arch/RISCV/RISCVModule.h
156+
Source/arch/RISCV/RISCVGenAsmWriter.inc
157+
Source/arch/RISCV/RISCVGenDisassemblerTables.inc
158+
Source/arch/RISCV/RISCVGenInsnNameMaps.inc
159+
Source/arch/RISCV/RISCVGenInstrInfo.inc
160+
Source/arch/RISCV/RISCVGenRegisterInfo.inc
161+
Source/arch/RISCV/RISCVGenSubtargetInfo.inc
162+
Source/arch/RISCV/RISCVMappingInsn.inc
163+
)
164+
endif()
123165

124166
set(capstone_SOURCES
125167
${SOURCES_ENGINE}
126168
${SOURCES_ARM}
127-
${SOURCES_MIPS}
169+
${SOURCES_ARM64}
170+
${SOURCES_RISCV}
128171
)
129172

130173
set(capstone_HEADERS
131174
${HEADERS_COMMON}
132175
${HEADERS_ENGINE}
133176
${HEADERS_ARM}
134-
${HEADERS_MIPS}
177+
${HEADERS_ARM64}
178+
${HEADERS_RISCV}
135179
)
136180

137181
set(capstone_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/capstone/Source/include")
@@ -145,6 +189,7 @@ if (COMPILER_IS_GCC_OR_CLANG)
145189
WEBKIT_ADD_TARGET_C_FLAGS(capstone
146190
-Wno-sign-compare
147191
-Wno-unused-parameter
192+
-Wno-ignored-qualifiers
148193
-Wno-implicit-fallthrough
149194
-Wno-missing-field-initializers
150195
-Wno-missing-format-attribute
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# clang-format configuration file. Intended for clang-format >= 11.
4+
#
5+
# For more information, see:
6+
#
7+
# Documentation/process/clang-format.rst
8+
# https://clang.llvm.org/docs/ClangFormat.html
9+
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
10+
#
11+
---
12+
AccessModifierOffset: -4
13+
AlignAfterOpenBracket: Align
14+
AlignConsecutiveAssignments: false
15+
AlignConsecutiveDeclarations: false
16+
AlignEscapedNewlines: DontAlign
17+
AlignOperands: true
18+
AlignTrailingComments:
19+
Kind: Always
20+
OverEmptyLines: 2
21+
AllowAllParametersOfDeclarationOnNextLine: false
22+
AllowShortBlocksOnASingleLine: false
23+
AllowShortCaseLabelsOnASingleLine: false
24+
AllowShortFunctionsOnASingleLine: None
25+
AllowShortIfStatementsOnASingleLine: false
26+
AllowShortLoopsOnASingleLine: false
27+
AlwaysBreakAfterDefinitionReturnType: None
28+
AlwaysBreakAfterReturnType: None
29+
AlwaysBreakBeforeMultilineStrings: false
30+
AlwaysBreakTemplateDeclarations: false
31+
BinPackArguments: true
32+
BinPackParameters: true
33+
BraceWrapping:
34+
AfterClass: false
35+
AfterControlStatement: false
36+
AfterEnum: false
37+
AfterFunction: true
38+
AfterNamespace: true
39+
AfterObjCDeclaration: false
40+
AfterStruct: false
41+
AfterUnion: false
42+
AfterExternBlock: false
43+
BeforeCatch: false
44+
BeforeElse: false
45+
IndentBraces: false
46+
SplitEmptyFunction: true
47+
SplitEmptyRecord: true
48+
SplitEmptyNamespace: true
49+
BreakBeforeBinaryOperators: None
50+
BreakBeforeBraces: Custom
51+
BreakBeforeInheritanceComma: false
52+
BreakBeforeTernaryOperators: false
53+
BreakConstructorInitializersBeforeComma: false
54+
BreakConstructorInitializers: BeforeComma
55+
BreakAfterJavaFieldAnnotations: false
56+
BreakStringLiterals: false
57+
ColumnLimit: 80
58+
CommentPragmas: '^ IWYU pragma:'
59+
CompactNamespaces: false
60+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
61+
ConstructorInitializerIndentWidth: 8
62+
ContinuationIndentWidth: 8
63+
Cpp11BracedListStyle: false
64+
DerivePointerAlignment: false
65+
DisableFormat: false
66+
ExperimentalAutoDetectBinPacking: false
67+
FixNamespaceComments: false
68+
69+
IncludeBlocks: Preserve
70+
IncludeCategories:
71+
- Regex: '.*'
72+
Priority: 1
73+
IncludeIsMainRegex: '(Test)?$'
74+
IndentCaseLabels: false
75+
IndentGotoLabels: false
76+
IndentPPDirectives: None
77+
IndentWidth: 8
78+
IndentWrappedFunctionNames: false
79+
JavaScriptQuotes: Leave
80+
JavaScriptWrapImports: true
81+
KeepEmptyLinesAtTheStartOfBlocks: false
82+
MacroBlockBegin: ''
83+
MacroBlockEnd: ''
84+
MaxEmptyLinesToKeep: 1
85+
NamespaceIndentation: None
86+
ObjCBinPackProtocolList: Auto
87+
ObjCBlockIndentWidth: 8
88+
ObjCSpaceAfterProperty: true
89+
ObjCSpaceBeforeProtocolList: true
90+
91+
# Taken from git's rules
92+
PenaltyBreakAssignment: 10
93+
PenaltyBreakBeforeFirstCallParameter: 30
94+
PenaltyBreakComment: 10
95+
PenaltyBreakFirstLessLess: 0
96+
PenaltyBreakString: 10
97+
PenaltyExcessCharacter: 100
98+
PenaltyReturnTypeOnItsOwnLine: 60
99+
100+
PointerAlignment: Right
101+
ReflowComments: false
102+
SortIncludes: false
103+
SortUsingDeclarations: false
104+
SpaceAfterCStyleCast: false
105+
SpaceAfterTemplateKeyword: true
106+
SpaceBeforeAssignmentOperators: true
107+
SpaceBeforeCtorInitializerColon: true
108+
SpaceBeforeInheritanceColon: true
109+
SpaceBeforeParens: ControlStatementsExceptForEachMacros
110+
SpaceBeforeRangeBasedForLoopColon: true
111+
SpaceInEmptyParentheses: false
112+
SpacesBeforeTrailingComments: 1
113+
SpacesInAngles: false
114+
SpacesInContainerLiterals: false
115+
SpacesInCStyleCastParentheses: false
116+
SpacesInParentheses: false
117+
SpacesInSquareBrackets: false
118+
Standard: Cpp03
119+
TabWidth: 8
120+
UseTab: Always
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.{py,pyx,pxd}]
8+
indent_style = space
9+
indent_size = 4
10+
11+
# Follow Linux kernel coding style
12+
[*.{c,h,cpp,hpp,inc}]
13+
indent_style = tab
14+
indent_size = 8
15+
16+
# OCaml bindings
17+
[*.ml]
18+
indent_style = tab
19+
indent_size = 4
20+
21+
[Makefile]
22+
indent_style = tab
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/arch/**/*.inc linguist-language=C
2+
3+
# Ensure shell scripts have LF line endings
4+
*.sh text eol=lf

0 commit comments

Comments
 (0)