Title: [231118] trunk/Source/_javascript_Core
Revision
231118
Author
[email protected]
Date
2018-04-27 17:01:14 -0700 (Fri, 27 Apr 2018)

Log Message

[JSC][ARM64][Linux] Add collectCPUFeatures using auxiliary vector
https://bugs.webkit.org/show_bug.cgi?id=185055

Reviewed by JF Bastien.

This patch is paving the way to emitting jscvt instruction if possible.
To do that, we need to determine jscvt instruction is supported in the
given CPU.

We add a function collectCPUFeatures, which is responsible to collect
CPU features if necessary. In Linux, we can use auxiliary vector to get
the information without parsing /proc/cpuinfo.

Currently, nobody calls this function. It is later called when we emit
jscvt instruction. To make it possible, we also need to add disassembler
support too.

* assembler/AbstractMacroAssembler.h:
* assembler/MacroAssemblerARM64.cpp:
(JSC::MacroAssemblerARM64::collectCPUFeatures):
* assembler/MacroAssemblerARM64.h:
* assembler/MacroAssemblerX86Common.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (231117 => 231118)


--- trunk/Source/_javascript_Core/ChangeLog	2018-04-27 23:46:31 UTC (rev 231117)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-04-28 00:01:14 UTC (rev 231118)
@@ -1,3 +1,28 @@
+2018-04-27  Yusuke Suzuki  <[email protected]>
+
+        [JSC][ARM64][Linux] Add collectCPUFeatures using auxiliary vector
+        https://bugs.webkit.org/show_bug.cgi?id=185055
+
+        Reviewed by JF Bastien.
+
+        This patch is paving the way to emitting jscvt instruction if possible.
+        To do that, we need to determine jscvt instruction is supported in the
+        given CPU.
+
+        We add a function collectCPUFeatures, which is responsible to collect
+        CPU features if necessary. In Linux, we can use auxiliary vector to get
+        the information without parsing /proc/cpuinfo.
+
+        Currently, nobody calls this function. It is later called when we emit
+        jscvt instruction. To make it possible, we also need to add disassembler
+        support too.
+
+        * assembler/AbstractMacroAssembler.h:
+        * assembler/MacroAssemblerARM64.cpp:
+        (JSC::MacroAssemblerARM64::collectCPUFeatures):
+        * assembler/MacroAssemblerARM64.h:
+        * assembler/MacroAssemblerX86Common.h:
+
 2018-04-26  Filip Pizlo  <[email protected]>
 
         Also run foldPathConstants before mussing up SSA

Modified: trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h (231117 => 231118)


--- trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2018-04-27 23:46:31 UTC (rev 231117)
+++ trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2018-04-28 00:01:14 UTC (rev 231118)
@@ -82,6 +82,12 @@
     template<PtrTag tag> using CodePtr = MacroAssemblerCodePtr<tag>;
     template<PtrTag tag> using CodeRef = MacroAssemblerCodeRef<tag>;
 
+    enum class CPUIDCheckState {
+        NotChecked,
+        Clear,
+        Set
+    };
+
     class Jump;
 
     typedef typename AssemblerType::RegisterID RegisterID;

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.cpp (231117 => 231118)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.cpp	2018-04-27 23:46:31 UTC (rev 231117)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.cpp	2018-04-28 00:01:14 UTC (rev 231118)
@@ -31,6 +31,11 @@
 #include "ProbeContext.h"
 #include <wtf/InlineASM.h>
 
+#if OS(LINUX)
+#include <asm/hwcap.h>
+#include <sys/auxv.h>
+#endif
+
 namespace JSC {
 
 #if ENABLE(MASM_PROBE)
@@ -526,6 +531,34 @@
 
 #endif // ENABLE(MASM_PROBE)
 
+void MacroAssemblerARM64::collectCPUFeatures()
+{
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [] {
+#if OS(LINUX)
+        // A register for describing ARM64 CPU features are only accessible in kernel mode.
+        // Thus, some kernel support is necessary to collect CPU features. In Linux, the
+        // kernel passes CPU feature flags in AT_HWCAP auxiliary vector which is passed
+        // when the process starts. While this may pose a bit conservative information
+        // (for example, the Linux kernel may add a flag for a feature after the feature
+        // is shipped and implemented in some CPUs. In that case, even if the CPU has
+        // that feature, the kernel does not tell it to users.), it is a stable approach.
+        // https://www.kernel.org/doc/Documentation/arm64/elf_hwcaps.txt
+        unsigned long hwcaps = getauxval(AT_HWCAP);
+
+#if !defined(HWCAP_JSCVT)
+#define HWCAP_JSCVT (1 << 13)
+#endif
+
+        s_jscvtCheckState = (hwcaps & HWCAP_JSCVT) ? CPUIDCheckState::Set : CPUIDCheckState::Clear;
+#else
+        s_jscvtCheckState = CPUIDCheckState::Clear;
+#endif
+    });
+}
+
+MacroAssemblerARM64::CPUIDCheckState MacroAssemblerARM64::s_jscvtCheckState = CPUIDCheckState::NotChecked;
+
 } // namespace JSC
 
 #endif // ENABLE(ASSEMBLER) && CPU(ARM64)

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h (231117 => 231118)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h	2018-04-27 23:46:31 UTC (rev 231117)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h	2018-04-28 00:01:14 UTC (rev 231118)
@@ -4460,6 +4460,10 @@
             Assembler::linkCall(code, call.m_label, function.template retaggedExecutableAddress<NoPtrTag>());
     }
 
+    JS_EXPORT_PRIVATE static void collectCPUFeatures();
+
+    JS_EXPORT_PRIVATE static CPUIDCheckState s_jscvtCheckState;
+
     CachedTempRegister m_dataMemoryTempRegister;
     CachedTempRegister m_cachedMemoryTempRegister;
     bool m_makeJumpPatchable;

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h (231117 => 231118)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h	2018-04-27 23:46:31 UTC (rev 231117)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h	2018-04-28 00:01:14 UTC (rev 231118)
@@ -4188,11 +4188,6 @@
     static CPUID getCPUIDEx(unsigned level, unsigned count);
     JS_EXPORT_PRIVATE static void collectCPUFeatures();
 
-    enum class CPUIDCheckState {
-        NotChecked,
-        Clear,
-        Set
-    };
     JS_EXPORT_PRIVATE static CPUIDCheckState s_sse2CheckState;
     JS_EXPORT_PRIVATE static CPUIDCheckState s_sse4_1CheckState;
     JS_EXPORT_PRIVATE static CPUIDCheckState s_sse4_2CheckState;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to