Ignore:
Timestamp:
Sep 28, 2016, 1:30:44 PM (9 years ago)
Author:
[email protected]
Message:

Optimize B3->Air lowering of Fence on ARM
https://bugs.webkit.org/show_bug.cgi?id=162342

Reviewed by Geoffrey Garen.

This gives us comprehensive support for standalone fences on x86 and ARM. The changes are as
follows:

  • Sets in stone the rule that the heaps of a B3::Fence tell you what the fence protects. If the fence reads, it protects motion of stores. If the fence writes, it protects motion of loads. This allows us to express for example load-load fences in a portable way: on x86 they will just block B3 optimizations and emit no code, while on ARM you will get some fence.
  • Adds comprehensive support for WTF-style fences in the ARM assembler. I simplified it just a bit to match what B3, the main client, knows. There are three fences: MemoryFence, StoreFence, and LoadFence. On x86, MemoryFence is ortop while StoreFence and LoadFence emit no code. On ARM64, MemoryFence and LoadFence are dmb ish while StoreFence is dmb ishst.
  • Tests! To test this, I needed to teach the disassembler how to disassemble dmb ish and dmb ishst. I think that the canonical way to do it would be to create a group for dmb and then teach that group how to decode the operands. But I don't actually know what are all of the ways of encoding dmb, so I'd rather that unrecognized encodings fall through to the ".long blah" bailout. So, this creates explicit matching rules for "dmb ish" and "dmb ishst", which is the most conservative thing we can do.
  • assembler/ARM64Assembler.h:

(JSC::ARM64Assembler::dmbISH):
(JSC::ARM64Assembler::dmbISHST):
(JSC::ARM64Assembler::dmbSY): Deleted.

  • assembler/MacroAssemblerARM64.h:

(JSC::MacroAssemblerARM64::memoryFence):
(JSC::MacroAssemblerARM64::storeFence):
(JSC::MacroAssemblerARM64::loadFence):

  • assembler/MacroAssemblerX86Common.h:

(JSC::MacroAssemblerX86Common::storeFence):
(JSC::MacroAssemblerX86Common::loadFence):

  • b3/B3FenceValue.h:
  • b3/B3LowerToAir.cpp:

(JSC::B3::Air::LowerToAir::lower):

  • b3/air/AirOpcode.opcodes:
  • b3/testb3.cpp:

(JSC::B3::testMemoryFence):
(JSC::B3::testStoreFence):
(JSC::B3::testLoadFence):
(JSC::B3::run):
(JSC::B3::testX86MFence): Deleted.
(JSC::B3::testX86CompilerFence): Deleted.

  • disassembler/ARM64/A64DOpcode.cpp:

(JSC::ARM64Disassembler::A64DOpcodeDmbIsh::format):
(JSC::ARM64Disassembler::A64DOpcodeDmbIshSt::format):

  • disassembler/ARM64/A64DOpcode.h:

(JSC::ARM64Disassembler::A64DOpcodeDmbIsh::opName):
(JSC::ARM64Disassembler::A64DOpcodeDmbIshSt::opName):

Location:
trunk/Source/JavaScriptCore/disassembler/ARM64
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.cpp

    r172813 r206539  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8585    OPCODE_GROUP_ENTRY(0x15, A64DOpcodeCompareAndBranchImmediate),
    8686    OPCODE_GROUP_ENTRY(0x15, A64DOpcodeHint),
     87    OPCODE_GROUP_ENTRY(0x15, A64DOpcodeDmbIsh),
     88    OPCODE_GROUP_ENTRY(0x15, A64DOpcodeDmbIshSt),
    8789    OPCODE_GROUP_ENTRY(0x16, A64DOpcodeUnconditionalBranchImmediate),
    8890    OPCODE_GROUP_ENTRY(0x16, A64DOpcodeUnconditionalBranchRegister),
     
    824826}
    825827
     828const char* A64DOpcodeDmbIsh::format()
     829{
     830    appendInstructionName("dmb");
     831    appendString("ish");
     832    return m_formatBuffer;
     833}
     834
     835const char* A64DOpcodeDmbIshSt::format()
     836{
     837    appendInstructionName("dmb");
     838    appendString("ishst");
     839    return m_formatBuffer;
     840}
     841
    826842// A zero in an entry of the table means the instruction is Unallocated
    827843const char* const A64DOpcodeLoadStore::s_opNames[32] = {
  • trunk/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.h

    r206525 r206539  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    510510};
    511511
     512class A64DOpcodeDmbIsh : public A64DOpcode {
     513public:
     514    static const uint32_t mask = 0xffffffff;
     515    static const uint32_t pattern = 0xd5033bbf;
     516
     517    DEFINE_STATIC_FORMAT(A64DOpcodeDmbIsh, thisObj);
     518
     519    const char* format();
     520
     521    const char* opName() { return "dmb"; }
     522};
     523
     524class A64DOpcodeDmbIshSt : public A64DOpcode {
     525public:
     526    static const uint32_t mask = 0xffffffff;
     527    static const uint32_t pattern = 0xd5033abf;
     528
     529    DEFINE_STATIC_FORMAT(A64DOpcodeDmbIshSt, thisObj);
     530
     531    const char* format();
     532
     533    const char* opName() { return "dmb"; }
     534};
     535
    512536class A64DOpcodeLoadStore : public A64DOpcode {
    513537private:
Note: See TracChangeset for help on using the changeset viewer.