Changeset 231118 in webkit


Ignore:
Timestamp:
Apr 27, 2018 5:01:14 PM (6 years ago)
Author:
Yusuke Suzuki
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:
Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r231116 r231118  
     12018-04-27  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC][ARM64][Linux] Add collectCPUFeatures using auxiliary vector
     4        https://bugs.webkit.org/show_bug.cgi?id=185055
     5
     6        Reviewed by JF Bastien.
     7
     8        This patch is paving the way to emitting jscvt instruction if possible.
     9        To do that, we need to determine jscvt instruction is supported in the
     10        given CPU.
     11
     12        We add a function collectCPUFeatures, which is responsible to collect
     13        CPU features if necessary. In Linux, we can use auxiliary vector to get
     14        the information without parsing /proc/cpuinfo.
     15
     16        Currently, nobody calls this function. It is later called when we emit
     17        jscvt instruction. To make it possible, we also need to add disassembler
     18        support too.
     19
     20        * assembler/AbstractMacroAssembler.h:
     21        * assembler/MacroAssemblerARM64.cpp:
     22        (JSC::MacroAssemblerARM64::collectCPUFeatures):
     23        * assembler/MacroAssemblerARM64.h:
     24        * assembler/MacroAssemblerX86Common.h:
     25
    1262018-04-26  Filip Pizlo  <fpizlo@apple.com>
    227
  • trunk/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h

    r231027 r231118  
    8383    template<PtrTag tag> using CodeRef = MacroAssemblerCodeRef<tag>;
    8484
     85    enum class CPUIDCheckState {
     86        NotChecked,
     87        Clear,
     88        Set
     89    };
     90
    8591    class Jump;
    8692
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.cpp

    r230040 r231118  
    3131#include "ProbeContext.h"
    3232#include <wtf/InlineASM.h>
     33
     34#if OS(LINUX)
     35#include <asm/hwcap.h>
     36#include <sys/auxv.h>
     37#endif
    3338
    3439namespace JSC {
     
    527532#endif // ENABLE(MASM_PROBE)
    528533
     534void MacroAssemblerARM64::collectCPUFeatures()
     535{
     536    static std::once_flag onceKey;
     537    std::call_once(onceKey, [] {
     538#if OS(LINUX)
     539        // A register for describing ARM64 CPU features are only accessible in kernel mode.
     540        // Thus, some kernel support is necessary to collect CPU features. In Linux, the
     541        // kernel passes CPU feature flags in AT_HWCAP auxiliary vector which is passed
     542        // when the process starts. While this may pose a bit conservative information
     543        // (for example, the Linux kernel may add a flag for a feature after the feature
     544        // is shipped and implemented in some CPUs. In that case, even if the CPU has
     545        // that feature, the kernel does not tell it to users.), it is a stable approach.
     546        // https://www.kernel.org/doc/Documentation/arm64/elf_hwcaps.txt
     547        unsigned long hwcaps = getauxval(AT_HWCAP);
     548
     549#if !defined(HWCAP_JSCVT)
     550#define HWCAP_JSCVT (1 << 13)
     551#endif
     552
     553        s_jscvtCheckState = (hwcaps & HWCAP_JSCVT) ? CPUIDCheckState::Set : CPUIDCheckState::Clear;
     554#else
     555        s_jscvtCheckState = CPUIDCheckState::Clear;
     556#endif
     557    });
     558}
     559
     560MacroAssemblerARM64::CPUIDCheckState MacroAssemblerARM64::s_jscvtCheckState = CPUIDCheckState::NotChecked;
     561
    529562} // namespace JSC
    530563
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h

    r230748 r231118  
    44614461    }
    44624462
     4463    JS_EXPORT_PRIVATE static void collectCPUFeatures();
     4464
     4465    JS_EXPORT_PRIVATE static CPUIDCheckState s_jscvtCheckState;
     4466
    44634467    CachedTempRegister m_dataMemoryTempRegister;
    44644468    CachedTempRegister m_cachedMemoryTempRegister;
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h

    r230748 r231118  
    41894189    JS_EXPORT_PRIVATE static void collectCPUFeatures();
    41904190
    4191     enum class CPUIDCheckState {
    4192         NotChecked,
    4193         Clear,
    4194         Set
    4195     };
    41964191    JS_EXPORT_PRIVATE static CPUIDCheckState s_sse2CheckState;
    41974192    JS_EXPORT_PRIVATE static CPUIDCheckState s_sse4_1CheckState;
Note: See TracChangeset for help on using the changeset viewer.