Skip to content

Commit 93539d6

Browse files
committed
Auto generate bytecode information for bytecode parser and LLInt
https://bugs.webkit.org/show_bug.cgi?id=129181 Reviewed by Mark Lam. Source/JavaScriptCore: Added new bytecode/BytecodeList.json that contains a list of bytecodes and related helpers. It also includes bytecode length and other information used to generate files. Added a new generator, generate-bytecode-files that generates Bytecodes.h and InitBytecodes.asm in DerivedSources/JavaScriptCore/. Added the generation of these files to the "DerivedSource" build step. Slighty changed the build order, since the Bytecodes.h file is needed by JSCLLIntOffsetsExtractor. Moved the offline assembly to a separate step since it needs to be run after JSCLLIntOffsetsExtractor. Made related changes to OPCODE macros and their use. * CMakeLists.txt: * DerivedSources.make: * GNUmakefile.am: * GNUmakefile.list.am: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: * JavaScriptCore.vcxproj/copy-files.cmd: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/BytecodeList.json: Added. * bytecode/Opcode.h: (JSC::padOpcodeName): * generate-bytecode-files: Added. * llint/LLIntCLoop.cpp: (JSC::LLInt::CLoop::initialize): * llint/LLIntCLoop.h: * llint/LLIntData.cpp: (JSC::LLInt::initialize): * llint/LLIntOpcode.h: * llint/LowLevelInterpreter.asm: Source/WebKit: Added ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR} to WebKit_INCLUDE_DIRECTORIES due to new generated Bytecodes.h include file. * CMakeLists.txt: Source/WebKit2: Added ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR} to WebKit2_INCLUDE_DIRECTORIES due to new generated Bytecodes.h include file. * CMakeLists.txt: Canonical link: https://commits.webkit.org/147426@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent dc51645 commit 93539d6

21 files changed

Lines changed: 668 additions & 212 deletions

‎Source/JavaScriptCore/CMakeLists.txt‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -593,25 +593,32 @@ if (ENABLE_LLINT)
593593
offlineasm/x86.rb
594594
)
595595

596+
add_custom_command(
597+
OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/Bytecodes.h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InitBytecodes.asm
598+
MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/generate-bytecode-files
599+
DEPENDS ${JAVASCRIPTCORE_DIR}/generate-bytecode-files bytecode/BytecodeList.json
600+
COMMAND ${PYTHON_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/generate-bytecode-files --bytecodes_h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/Bytecodes.h --init_bytecodes_asm ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InitBytecodes.asm ${JAVASCRIPTCORE_DIR}/bytecode/BytecodeList.json
601+
VERBATIM)
602+
596603
add_custom_command(
597604
OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h
598605
MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/offlineasm/generate_offset_extractor.rb
599606
DEPENDS ${LLINT_ASM} ${OFFLINE_ASM}
600607
COMMAND ${RUBY_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/offlineasm/generate_offset_extractor.rb ${JAVASCRIPTCORE_DIR}/llint/LowLevelInterpreter.asm ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h
601608
VERBATIM)
602609

603-
# We add the header file directly to the ADD_EXECUTABLE call instead of setting the
604-
# OBJECT_DEPENDS property in LLIntOffsetsExtractor.cpp because generate_offset_extractor.rb may
605-
# not regenerate it in case the hash it calculates does not change.
606-
# In this case, if some of the dependencies specified in the ADD_CUSTOM_COMMAND above have
607-
# changed the command will always be called because the mtime of LLIntDesiredOffsets.h will
608-
# always be older than that of its dependencies.
609-
# Additionally, setting the OBJECT_DEPENDS property will make LLIntDesiredOffsets.h a Makefile
610+
# We add the header files directly to the ADD_EXECUTABLE call instead of setting the
611+
# OBJECT_DEPENDS property in LLIntOffsetsExtractor.cpp because generate_offset_extractor.rb and
612+
# generate-bytecode-files may not regenerate the .h files in case the hash it calculates does not change.
613+
# In this case, if some of the dependencies specified in the ADD_CUSTOM_COMMANDs above have
614+
# changed the command will always be called because the mtime of the .h files will
615+
# always be older than that of their dependencies.
616+
# Additionally, setting the OBJECT_DEPENDS property will make the .h files a Makefile
610617
# dependency of both LLIntOffsetsExtractor and LLIntOffsetsExtractor.cpp, so the command will
611-
# actually be run twice!
618+
# actually be run multiple times!
612619
add_executable(LLIntOffsetsExtractor
613620
${JAVASCRIPTCORE_DIR}/llint/LLIntOffsetsExtractor.cpp
614-
${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h
621+
${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/Bytecodes.h
615622
)
616623
target_link_libraries(LLIntOffsetsExtractor WTF)
617624

@@ -624,7 +631,7 @@ if (ENABLE_LLINT)
624631
add_custom_command(
625632
OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntAssembly.h
626633
MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/offlineasm/asm.rb
627-
DEPENDS LLIntOffsetsExtractor ${LLINT_ASM} ${OFFLINE_ASM}
634+
DEPENDS LLIntOffsetsExtractor ${LLINT_ASM} ${OFFLINE_ASM} ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InitBytecodes.asm
628635
COMMAND ${RUBY_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/offlineasm/asm.rb ${JAVASCRIPTCORE_DIR}/llint/LowLevelInterpreter.asm $<TARGET_FILE:LLIntOffsetsExtractor> ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntAssembly.h
629636
COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntAssembly.h
630637
VERBATIM)
@@ -789,6 +796,7 @@ set(JavaScriptCore_FORWARDING_HEADERS_FILES
789796
runtime/VM.h
790797

791798
${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/JSCBuiltins.h
799+
${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/Bytecodes.h
792800
)
793801

794802

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
2014-02-26 Michael Saboff <msaboff@apple.com>
2+
3+
Auto generate bytecode information for bytecode parser and LLInt
4+
https://bugs.webkit.org/show_bug.cgi?id=129181
5+
6+
Reviewed by Mark Lam.
7+
8+
Added new bytecode/BytecodeList.json that contains a list of bytecodes and related
9+
helpers. It also includes bytecode length and other information used to generate files.
10+
Added a new generator, generate-bytecode-files that generates Bytecodes.h and InitBytecodes.asm
11+
in DerivedSources/JavaScriptCore/.
12+
13+
Added the generation of these files to the "DerivedSource" build step.
14+
Slighty changed the build order, since the Bytecodes.h file is needed by
15+
JSCLLIntOffsetsExtractor. Moved the offline assembly to a separate step since it needs
16+
to be run after JSCLLIntOffsetsExtractor.
17+
18+
Made related changes to OPCODE macros and their use.
19+
20+
* CMakeLists.txt:
21+
* DerivedSources.make:
22+
* GNUmakefile.am:
23+
* GNUmakefile.list.am:
24+
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
25+
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
26+
* JavaScriptCore.vcxproj/copy-files.cmd:
27+
* JavaScriptCore.xcodeproj/project.pbxproj:
28+
* bytecode/BytecodeList.json: Added.
29+
* bytecode/Opcode.h:
30+
(JSC::padOpcodeName):
31+
* generate-bytecode-files: Added.
32+
* llint/LLIntCLoop.cpp:
33+
(JSC::LLInt::CLoop::initialize):
34+
* llint/LLIntCLoop.h:
35+
* llint/LLIntData.cpp:
36+
(JSC::LLInt::initialize):
37+
* llint/LLIntOpcode.h:
38+
* llint/LowLevelInterpreter.asm:
39+
140
2014-02-26 Mark Lam <mark.lam@apple.com>
241

342
ASSERTION FAILED: m_heap->vm()->currentThreadIsHoldingAPILock() in inspector-protocol/*.

‎Source/JavaScriptCore/DerivedSources.make‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ all : \
5858
RegExpObject.lut.h \
5959
StringConstructor.lut.h \
6060
udis86_itab.h \
61+
Bytecodes.h \
62+
InitBytecodes.asm \
6163
JSCBuiltins \
6264
#
6365

@@ -90,6 +92,13 @@ KeywordLookup.h: KeywordLookupGenerator.py Keywords.table
9092
udis86_itab.h: $(JavaScriptCore)/disassembler/udis86/itab.py $(JavaScriptCore)/disassembler/udis86/optable.xml
9193
(PYTHONPATH=$(JavaScriptCore)/disassembler/udis86 python $(JavaScriptCore)/disassembler/udis86/itab.py $(JavaScriptCore)/disassembler/udis86/optable.xml || exit 1)
9294

95+
# Bytecode files
96+
97+
Bytecodes.h: $(JavaScriptCore)/generate-bytecode-files $(JavaScriptCore)/bytecode/BytecodeList.json
98+
python $(JavaScriptCore)/generate-bytecode-files --bytecodes_h Bytecodes.h $(JavaScriptCore)/bytecode/BytecodeList.json
99+
100+
InitBytecodes.asm: $(JavaScriptCore)/generate-bytecode-files $(JavaScriptCore)/bytecode/BytecodeList.json
101+
python $(JavaScriptCore)/generate-bytecode-files --init_bytecodes_asm InitBytecodes.asm $(JavaScriptCore)/bytecode/BytecodeList.json
93102

94103
# Inspector interfaces
95104

‎Source/JavaScriptCore/GNUmakefile.am‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ pkgconfig_DATA += Source/JavaScriptCore/javascriptcoregtk-@WEBKITGTK_API_VERSION
9595

9696
$(shell mkdir -p DerivedSources/JavaScriptCore)
9797

98+
DerivedSources/JavaScriptCore/Bytecodes.h: $(srcdir)/Source/JavaScriptCore/generate-bytecode-files $(srcdir)/Source/JavaScriptCore/bytecode/BytecodeList.json
99+
$(AM_V_GEN)$(PYTHON) $(srcdir)/Source/JavaScriptCore/generate-bytecode-files --bytecodes_h $@ $(srcdir)/Source/JavaScriptCore/bytecode/BytecodeList.json
100+
101+
DerivedSources/JavaScriptCore/InitBytecodes.asm: $(srcdir)/Source/JavaScriptCore/generate-bytecode-files $(srcdir)/Source/JavaScriptCore/bytecode/BytecodeList.json
102+
$(AM_V_GEN)$(PYTHON) $(srcdir)/Source/JavaScriptCore/generate-bytecode-files --init_bytecodes_asm $@ $(srcdir)/Source/JavaScriptCore/bytecode/BytecodeList.json
103+
98104
DerivedSources/JavaScriptCore/Lexer.lut.h: $(srcdir)/Source/JavaScriptCore/create_hash_table $(srcdir)/Source/JavaScriptCore/parser/Keywords.table
99105
$(AM_V_GEN)$(PERL) $^ > $@
100106

@@ -111,9 +117,9 @@ DerivedSources/JavaScriptCore/LLIntDesiredOffsets.h: $(javascriptcore_sources) $
111117
$(AM_V_GEN)$(RUBY) $(srcdir)/Source/JavaScriptCore/offlineasm/generate_offset_extractor.rb $(srcdir)/Source/JavaScriptCore/llint/LowLevelInterpreter.asm $@
112118
$(AM_V_at)touch $@
113119

114-
$(Programs_LLIntOffsetsExtractor_OBJECTS): DerivedSources/JavaScriptCore/LLIntDesiredOffsets.h
120+
$(Programs_LLIntOffsetsExtractor_OBJECTS): DerivedSources/JavaScriptCore/LLIntDesiredOffsets.h DerivedSources/JavaScriptCore/Bytecodes.h
115121

116-
DerivedSources/JavaScriptCore/LLIntAssembly.h: Programs/LLIntOffsetsExtractor$(EXEEXT)
122+
DerivedSources/JavaScriptCore/LLIntAssembly.h: Programs/LLIntOffsetsExtractor$(EXEEXT) DerivedSources/JavaScriptCore/InitBytecodes.asm
117123
$(AM_V_GEN)$(RUBY) $(srcdir)/Source/JavaScriptCore/offlineasm/asm.rb $(srcdir)/Source/JavaScriptCore/llint/LowLevelInterpreter.asm Programs/LLIntOffsetsExtractor$(EXEEXT) $@
118124
$(AM_V_at)touch $@
119125

‎Source/JavaScriptCore/GNUmakefile.list.am‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ javascriptcore_built_nosources += \
3434
DerivedSources/JavaScriptCore/RegExpObject.lut.h \
3535
DerivedSources/JavaScriptCore/RegExpPrototype.lut.h \
3636
DerivedSources/JavaScriptCore/StringConstructor.lut.h \
37+
DerivedSources/JavaScriptCore/Bytecodes.h \
38+
DerivedSources/JavaScriptCore/InitBytecodes.asm \
3739
DerivedSources/JavaScriptCore/LLIntDesiredOffsets.h \
3840
DerivedSources/JavaScriptCore/LLIntAssembly.h
3941

‎Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@
14461446
<ClInclude Include="..\yarr\YarrSyntaxChecker.h" />
14471447
</ItemGroup>
14481448
<ItemGroup>
1449+
<None Include="..\bytecode\BytecodeList.json" />
14491450
<None Include="JavaScriptCorePostBuild.cmd">
14501451
<FileType>Document</FileType>
14511452
</None>

‎Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,6 +3336,9 @@
33363336
<None Include="JavaScriptCorePreLink.cmd" />
33373337
<None Include="JavaScriptCorePostBuild.cmd" />
33383338
<None Include="JavaScriptCorePreBuild.cmd" />
3339+
<None Include="..\bytecode\BytecodeList.json">
3340+
<Filter>bytecode</Filter>
3341+
</None>
33393342
</ItemGroup>
33403343
<ItemGroup>
33413344
<MASM Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\LowLevelInterpreterWin.asm" />

‎Source/JavaScriptCore/JavaScriptCore.vcxproj/copy-files.cmd‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ xcopy /y "%DerivedSourcesDirectory%\InspectorJSFrontendDispatchers.h" "%PrivateH
7575

7676
echo Copying builtins header as if it were a private header...
7777
xcopy /y "%DerivedSourcesDirectory%\JSCBuiltins.h" "%PrivateHeadersDirectory%" >NUL
78+
xcopy /y "%DerivedSourcesDirectory%\Bytecodes.h" "%PrivateHeadersDirectory%" >NUL
7879

7980
echo Copying resources...
8081
mkdir "%ResourcesDirectory%" 2>NUL

0 commit comments

Comments
 (0)