Title: [204084] trunk
Revision
204084
Author
o...@webkit.org
Date
2016-08-03 10:12:55 -0700 (Wed, 03 Aug 2016)

Log Message

Lacking support on a arm-traditional disassembler.
https://bugs.webkit.org/show_bug.cgi?id=123717

Reviewed by Mark Lam.

.:

* Source/cmake/FindLLVM.cmake: Added back the r196749 state.
* Source/cmake/OptionsCommon.cmake: Added back the r196749 state.

Source/_javascript_Core:

* CMakeLists.txt:
* disassembler/ARMLLVMDisassembler.cpp: Added, based on pre r196729 LLVMDisassembler, but it is ARM traditional only now.
(JSC::tryToDisassemble):

Source/WTF:

* wtf/Platform.h:

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (204083 => 204084)


--- trunk/ChangeLog	2016-08-03 16:53:15 UTC (rev 204083)
+++ trunk/ChangeLog	2016-08-03 17:12:55 UTC (rev 204084)
@@ -1,3 +1,13 @@
+2016-08-03  Csaba Osztrogonác  <o...@webkit.org>
+
+        Lacking support on a arm-traditional disassembler.
+        https://bugs.webkit.org/show_bug.cgi?id=123717
+
+        Reviewed by Mark Lam.
+
+        * Source/cmake/FindLLVM.cmake: Added back the r196749 state.
+        * Source/cmake/OptionsCommon.cmake: Added back the r196749 state.
+
 2016-08-01  Keith Miller  <keith_mil...@apple.com>
 
         We should not keep the _javascript_ tests inside the Source/_javascript_Core/ directory.

Modified: trunk/Source/_javascript_Core/CMakeLists.txt (204083 => 204084)


--- trunk/Source/_javascript_Core/CMakeLists.txt	2016-08-03 16:53:15 UTC (rev 204083)
+++ trunk/Source/_javascript_Core/CMakeLists.txt	2016-08-03 17:12:55 UTC (rev 204084)
@@ -383,6 +383,7 @@
     dfg/DFGWorklist.cpp
 
     disassembler/ARM64Disassembler.cpp
+    disassembler/ARMLLVMDisassembler.cpp
     disassembler/ARMv7Disassembler.cpp
     disassembler/Disassembler.cpp
     disassembler/UDis86Disassembler.cpp
@@ -893,6 +894,7 @@
 set(_javascript_Core_LIBRARIES
     WTF${DEBUG_SUFFIX}
     ${ICU_I18N_LIBRARIES}
+    ${LLVM_LIBRARIES}
 )
 
 set(_javascript_Core_SCRIPTS_SOURCES_DIR "${_javascript_CORE_DIR}/Scripts")

Modified: trunk/Source/_javascript_Core/ChangeLog (204083 => 204084)


--- trunk/Source/_javascript_Core/ChangeLog	2016-08-03 16:53:15 UTC (rev 204083)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-08-03 17:12:55 UTC (rev 204084)
@@ -1,3 +1,14 @@
+2016-08-03  Csaba Osztrogonác  <o...@webkit.org>
+
+        Lacking support on a arm-traditional disassembler.
+        https://bugs.webkit.org/show_bug.cgi?id=123717
+
+        Reviewed by Mark Lam.
+
+        * CMakeLists.txt:
+        * disassembler/ARMLLVMDisassembler.cpp: Added, based on pre r196729 LLVMDisassembler, but it is ARM traditional only now.
+        (JSC::tryToDisassemble):
+
 2016-08-03  Saam Barati  <sbar...@apple.com>
 
         Implement nested rest destructuring w.r.t the ES7 spec

Added: trunk/Source/_javascript_Core/disassembler/ARMLLVMDisassembler.cpp (0 => 204084)


--- trunk/Source/_javascript_Core/disassembler/ARMLLVMDisassembler.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/disassembler/ARMLLVMDisassembler.cpp	2016-08-03 17:12:55 UTC (rev 204084)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Disassembler.h"
+
+#if USE(ARM_LLVM_DISASSEMBLER)
+
+#include "MacroAssemblerCodeRef.h"
+#include <llvm-c/Disassembler.h>
+#include <llvm-c/Target.h>
+
+namespace JSC {
+
+bool tryToDisassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out)
+{
+    LLVMInitializeAllTargetInfos();
+    LLVMInitializeAllTargetMCs();
+    LLVMInitializeAllDisassemblers();
+
+    const char* triple = "armv7-unknown-linux-gnueabihf";
+    LLVMDisasmContextRef disassemblyContext = LLVMCreateDisasm(triple, 0, 0, 0, 0);
+
+    RELEASE_ASSERT(disassemblyContext);
+
+    char pcString[20];
+    char instructionString[100];
+
+    uint8_t* pc = static_cast<uint8_t*>(codePtr.executableAddress());
+    uint8_t* end = pc + size;
+
+    while (pc < end) {
+        snprintf(
+            pcString, sizeof(pcString), "0x%lx",
+            static_cast<unsigned long>(bitwise_cast<uintptr_t>(pc)));
+
+        size_t instructionSize = LLVMDisasmInstruction(
+            disassemblyContext, pc, end - pc, bitwise_cast<uintptr_t>(pc),
+            instructionString, sizeof(instructionString));
+
+        if (!instructionSize)
+            snprintf(instructionString, sizeof(instructionString), "unknown instruction");
+
+        out.printf("%s%16s: [0x%08lx] %s\n", prefix, pcString, *(reinterpret_cast<unsigned long*>(pc)), instructionString);
+        pc += 4;
+    }
+
+    LLVMDisasmDispose(disassemblyContext);
+    return true;
+}
+
+} // namespace JSC
+
+#endif // USE(ARM_LLVM_DISASSEMBLER)

Modified: trunk/Source/WTF/ChangeLog (204083 => 204084)


--- trunk/Source/WTF/ChangeLog	2016-08-03 16:53:15 UTC (rev 204083)
+++ trunk/Source/WTF/ChangeLog	2016-08-03 17:12:55 UTC (rev 204084)
@@ -1,3 +1,12 @@
+2016-08-03  Csaba Osztrogonác  <o...@webkit.org>
+
+        Lacking support on a arm-traditional disassembler.
+        https://bugs.webkit.org/show_bug.cgi?id=123717
+
+        Reviewed by Mark Lam.
+
+        * wtf/Platform.h:
+
 2016-08-02  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Update breaking rules to match ICU 57

Modified: trunk/Source/WTF/wtf/Platform.h (204083 => 204084)


--- trunk/Source/WTF/wtf/Platform.h	2016-08-03 16:53:15 UTC (rev 204083)
+++ trunk/Source/WTF/wtf/Platform.h	2016-08-03 17:12:55 UTC (rev 204084)
@@ -743,7 +743,11 @@
 #define USE_ARMV7_DISASSEMBLER 1
 #endif
 
-#if !defined(ENABLE_DISASSEMBLER) && (USE(UDIS86) || USE(ARMV7_DISASSEMBLER) || USE(ARM64_DISASSEMBLER))
+#if !defined(USE_ARM_LLVM_DISASSEMBLER) && ENABLE(JIT) && CPU(ARM_TRADITIONAL) && HAVE(LLVM)
+#define USE_ARM_LLVM_DISASSEMBLER 1
+#endif
+
+#if !defined(ENABLE_DISASSEMBLER) && (USE(UDIS86) || USE(ARMV7_DISASSEMBLER) || USE(ARM64_DISASSEMBLER) || USE(ARM_LLVM_DISASSEMBLER))
 #define ENABLE_DISASSEMBLER 1
 #endif
 

Added: trunk/Source/cmake/FindLLVM.cmake (0 => 204084)


--- trunk/Source/cmake/FindLLVM.cmake	                        (rev 0)
+++ trunk/Source/cmake/FindLLVM.cmake	2016-08-03 17:12:55 UTC (rev 204084)
@@ -0,0 +1,49 @@
+#
+# Check if the llvm-config gives us the path for the llvm libs.
+#
+# The following variables are set:
+#  LLVM_CONFIG_EXE
+#  LLVM_VERSION
+#  LLVM_INCLUDE_DIRS - include directories for the llvm headers.
+#  LLVM_STATIC_LIBRARIES - list of paths for the static llvm libraries.
+
+
+foreach (_program_name llvm-config llvm-config-3.7 llvm-config-3.6 llvm-config-3.5)
+    find_program(LLVM_CONFIG_EXE NAMES ${_program_name})
+    if (LLVM_CONFIG_EXE)
+        execute_process(COMMAND ${LLVM_CONFIG_EXE} --version OUTPUT_VARIABLE LLVM_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
+        if ("${LLVM_VERSION}" VERSION_LESS "${LLVM_FIND_VERSION}")
+            unset(LLVM_CONFIG_EXE CACHE)
+        else ()
+            break ()
+        endif ()
+    endif ()
+endforeach ()
+
+execute_process(COMMAND ${LLVM_CONFIG_EXE} --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND ${LLVM_CONFIG_EXE} --libfiles OUTPUT_VARIABLE LLVM_STATIC_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND ${LLVM_CONFIG_EXE} --system-libs OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND ${LLVM_CONFIG_EXE} --libdir OUTPUT_VARIABLE LLVM_LIBS_DIRECTORY OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND ${LLVM_CONFIG_EXE} --libs OUTPUT_VARIABLE LLVM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND ${LLVM_CONFIG_EXE} --ldflags OUTPUT_VARIABLE LLVM_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+# Depending on how llvm was built, we could have either a global .so file when built using autotools,
+# or multiple .so files for each static library when built using CMake. So, we set the LLVM_LIBS_DIRECTORY
+# variable here accordingly for each case.
+# We need to build the soname manually in any case, since there's currently no way to get it from llvm-config.
+set(LLVM_SONAME "LLVM-${LLVM_VERSION}")
+if (EXISTS "${LLVM_LIBS_DIRECTORY}/lib${LLVM_SONAME}.so")
+    set(LLVM_LIBRARIES "${LLVM_LDFLAGS} -l${LLVM_SONAME}")
+else ()
+    set(LLVM_LIBRARIES "${LLVM_LDFLAGS} ${LLVM_LIBS}")
+endif ()
+
+# convert the list of paths into a cmake list
+separate_arguments(LLVM_STATIC_LIBRARIES)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LLVM
+                                  REQUIRED_VARS LLVM_VERSION LLVM_INCLUDE_DIRS LLVM_LIBRARIES LLVM_STATIC_LIBRARIES
+                                  VERSION_VAR LLVM_VERSION)
+
+mark_as_advanced(LLVM_VERSION LLVM_INCLUDE_DIRS LLVM_LIBRARIES LLVM_STATIC_LIBRARIES)

Modified: trunk/Source/cmake/OptionsCommon.cmake (204083 => 204084)


--- trunk/Source/cmake/OptionsCommon.cmake	2016-08-03 16:53:15 UTC (rev 204083)
+++ trunk/Source/cmake/OptionsCommon.cmake	2016-08-03 17:12:55 UTC (rev 204084)
@@ -144,6 +144,11 @@
     set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
 endif ()
 
+if (USE_ARM_LLVM_DISASSEMBLER)
+    find_package(LLVM REQUIRED)
+    SET_AND_EXPOSE_TO_BUILD(HAVE_LLVM TRUE)
+endif ()
+
 # Enable the usage of OpenMP.
 #  - At this moment, OpenMP is only used as an alternative implementation
 #    to native threads for the parallelization of the SVG filters.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to