goal: the FTL only supported on Darwin, but we want it workable on linux for study FTL implementation
Platform: X86_64
LLVM version: c84ba8
WebKit version: 5d442a
LLVM:
LLVM should has stackmap implementation in ELF, grep .llvm_stackmaps in$llvm/lib/MC/MCObjectFileInfo.cpp
patch for walkaround eh_frame relocation error
jsc: $llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:308:
void llvm::RuntimeDyldELF::resolveX86_64Relocation(const llvm::SectionEntry&, uint64_t,
uint64_t, uint32_t, int64_t, uint64_t): Assertion `RealOffset <= (2147483647)
&& RealOffset >=
(-2147483647-1)' failed.
Aborted
Aborted
index a592c09..9231cbe 100644
--- a/lib/MC/MCDwarf.cpp
+++ b/lib/MC/MCDwarf.cpp
@@ -999,7 +999,7 @@ static void emitFDESymbol(MCObjectStreamer &streamer, const MCSym
if (asmInfo->doDwarfFDESymbolsUseAbsDiff() && isEH)
emitAbsValue(streamer, v, size);
else
- streamer.EmitValue(v, size);
+ streamer.EmitValue(v, isEH ? 8 : size);
}
patch for webkit
1.
--- a/Source/JavaScriptCore/CMakeLists.txt
+++ b/Source/JavaScriptCore/CMakeLists.txt
@@ -740,7 +740,7 @@ if (ENABLE_FTL_JIT)
WEBKIT_WRAP_SOURCELIST(${llvmForJSC_SOURCES})
add_library(llvmForJSC SHARED ${llvmForJSC_SOURCES} ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/WebKitLLVMLibraryToken.h)
- target_link_libraries(llvmForJSC ${LLVM_STATIC_LIBRARIES} "pthread" "dl")
+ target_link_libraries(llvmForJSC ${LLVM_STATIC_LIBRARIES} "pthread" "dl" "z" "curses")
2.
--- a/Source/JavaScriptCore/ftl/FTLCompile.cpp
+++ b/Source/JavaScriptCore/ftl/FTLCompile.cpp
@@ -621,12 +624,21 @@ void compile(State& state, Safepoint::Result& safepointResult)
if (isARM64())llvm->SetTarget(state.module, "arm64-apple-ios");
-
+
+#if OS(LINUX) && CPU(X86_64)
+ llvm->SetTarget(state.module, "x86_64-unknown-linux-gnu");
+#elif OS(LINUX) && CPU(X86)
+ llvm->SetTarget(state.module, "x86-unknown-linux-gnu");
+#endif
3.
--- a/Source/JavaScriptCore/disassembler/LLVMDisassembler.cpp
+++ b/Source/JavaScriptCore/disassembler/LLVMDisassembler.cpp
@@ -87,6 +87,8 @@ bool tryToDisassembleWithLLVM(
triple = "x86_64-apple-darwin";
#elif CPU(X86)
triple = "x86-apple-darwin";
+#elif CPU(X86_64) && OS(LINUX)
+ triple = "x86_64-unknown-linux-gnu";
#elif CPU(ARM64)
triple = "arm64-apple-darwin";
4.
--- a/Source/JavaScriptCore/ftl/FTLCompile.cpp
+++ b/Source/JavaScriptCore/ftl/FTLCompile.cpp
@@ -87,7 +87,7 @@ static uint8_t* mmAllocateDataSection(
RefPtr<DataSection> section = adoptRef(new DataSection(size, alignment));
- if (!strcmp(sectionName, "__llvm_stackmaps"))
+ if (!strcmp(sectionName, ".llvm_stackmaps"))
state.stackmapsSection = section;
else {
state.jitCode->addDataSection(section);
5.
--- a/Source/JavaScriptCore/ftl/FTLUnwindInfo.cpp
+++ b/Source/JavaScriptCore/ftl/FTLUnwindInfo.cpp
@@ -28,7 +28,7 @@
#if ENABLE(FTL_JIT)
-#include <mach-o/compact_unwind_encoding.h>
+#include "compact_unwind_encoding.h"
6.
download compact_unwind_encoding.h and put it to $webkit/Source/JavaScriptCore/ftl
build command
$export PATH=$PATH:$llvm/install/bin
$./Tools/Scripts/build-jsc --gtk --debug --ftl-jit --cmakeargs="-DENABLE_PLUGIN_PROCESS_GTK2=OFF -DLIBCXXABI_INCLUDE_DIRS=/usr/include/c++/4.8/ -DENABLE_VIDEO=OFF -DENABLE_VIDEO_TRACK=OFF -DENABLE_VIEW_MODE_CSS_MEDIA=OFF -DENABLE_WEB_AUDIO=OFF" --makeargs="VERBOSE=1"
$./Tools/Scripts/build-jsc --gtk --debug --ftl-jit --cmakeargs="-DENABLE_PLUGIN_PROCESS_GTK2=OFF -DLIBCXXABI_INCLUDE_DIRS=/usr/include/c++/4.8/ -DENABLE_VIDEO=OFF -DENABLE_VIDEO_TRACK=OFF -DENABLE_VIEW_MODE_CSS_MEDIA=OFF -DENABLE_WEB_AUDIO=OFF" --makeargs="VERBOSE=1"
Running and Testing
export JSC_enableConcurrentJIT=false./Tools/Scripts/run-jsc-stress-tests -root=$WebKit/ WebKitBuild/Debug/bin/
Results for JSC stress tests:
12 failures found.
沒有留言:
張貼留言