Changeset 195159 in webkit


Ignore:
Timestamp:
Jan 15, 2016 4:37:29 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] Legalize Memory Offsets for ARM64 before lowering to Air
https://bugs.webkit.org/show_bug.cgi?id=153065

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-01-15
Reviewed by Mark Lam.
Reviewed by Filip Pizlo.

On ARM64, we cannot use signed 32bits offset for memory addressing.
There are two available addressing: signed 9bits and unsigned scaled 12bits.
Air already knows about it.

In this patch, the offsets are changed to something valid for ARM64
prior to lowering. When an offset is invalid, it is just computed
before the instruction and used as the base for addressing.

(JSC::B3::generateToAir):

  • b3/B3LegalizeMemoryOffsets.cpp: Added.

(JSC::B3::legalizeMemoryOffsets):

  • b3/B3LegalizeMemoryOffsets.h: Added.
  • b3/B3LowerToAir.cpp:

(JSC::B3::Air::LowerToAir::effectiveAddr): Deleted.

  • b3/testb3.cpp:

(JSC::B3::testLoadWithOffsetImpl):
(JSC::B3::testLoadOffsetImm9Max):
(JSC::B3::testLoadOffsetImm9MaxPlusOne):
(JSC::B3::testLoadOffsetImm9MaxPlusTwo):
(JSC::B3::testLoadOffsetImm9Min):
(JSC::B3::testLoadOffsetImm9MinMinusOne):
(JSC::B3::testLoadOffsetScaledUnsignedImm12Max):
(JSC::B3::testLoadOffsetScaledUnsignedOverImm12Max):
(JSC::B3::run):

Location:
trunk/Source/JavaScriptCore
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r195155 r195159  
     12016-01-15  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Legalize Memory Offsets for ARM64 before lowering to Air
     4        https://bugs.webkit.org/show_bug.cgi?id=153065
     5
     6        Reviewed by Mark Lam.
     7        Reviewed by Filip Pizlo.
     8
     9        On ARM64, we cannot use signed 32bits offset for memory addressing.
     10        There are two available addressing: signed 9bits and unsigned scaled 12bits.
     11        Air already knows about it.
     12
     13        In this patch, the offsets are changed to something valid for ARM64
     14        prior to lowering. When an offset is invalid, it is just computed
     15        before the instruction and used as the base for addressing.
     16
     17        * JavaScriptCore.xcodeproj/project.pbxproj:
     18        * b3/B3Generate.cpp:
     19        (JSC::B3::generateToAir):
     20        * b3/B3LegalizeMemoryOffsets.cpp: Added.
     21        (JSC::B3::legalizeMemoryOffsets):
     22        * b3/B3LegalizeMemoryOffsets.h: Added.
     23        * b3/B3LowerToAir.cpp:
     24        (JSC::B3::Air::LowerToAir::effectiveAddr): Deleted.
     25        * b3/testb3.cpp:
     26        (JSC::B3::testLoadWithOffsetImpl):
     27        (JSC::B3::testLoadOffsetImm9Max):
     28        (JSC::B3::testLoadOffsetImm9MaxPlusOne):
     29        (JSC::B3::testLoadOffsetImm9MaxPlusTwo):
     30        (JSC::B3::testLoadOffsetImm9Min):
     31        (JSC::B3::testLoadOffsetImm9MinMinusOne):
     32        (JSC::B3::testLoadOffsetScaledUnsignedImm12Max):
     33        (JSC::B3::testLoadOffsetScaledUnsignedOverImm12Max):
     34        (JSC::B3::run):
     35
    1362016-01-15  Alex Christensen  <achristensen@webkit.org>
    237
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r195139 r195159  
    11691169                43422A661C16267500E2EB98 /* B3ReduceDoubleToFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43422A641C16221E00E2EB98 /* B3ReduceDoubleToFloat.cpp */; };
    11701170                43422A671C16267800E2EB98 /* B3ReduceDoubleToFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 43422A651C16221E00E2EB98 /* B3ReduceDoubleToFloat.h */; };
     1171                436E54531C468E7400B5AF73 /* B3LegalizeMemoryOffsets.h in Headers */ = {isa = PBXBuildFile; fileRef = 436E54521C468E5F00B5AF73 /* B3LegalizeMemoryOffsets.h */; };
     1172                436E54541C468E7700B5AF73 /* B3LegalizeMemoryOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 436E54511C468E5F00B5AF73 /* B3LegalizeMemoryOffsets.cpp */; };
    11711173                43AB26C61C1A535900D82AE6 /* B3MathExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 43AB26C51C1A52F700D82AE6 /* B3MathExtras.h */; };
    11721174                43AB26C71C1A535C00D82AE6 /* B3MathExtras.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43AB26C41C1A52F700D82AE6 /* B3MathExtras.cpp */; };
     
    32983300                43422A641C16221E00E2EB98 /* B3ReduceDoubleToFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3ReduceDoubleToFloat.cpp; path = b3/B3ReduceDoubleToFloat.cpp; sourceTree = "<group>"; };
    32993301                43422A651C16221E00E2EB98 /* B3ReduceDoubleToFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3ReduceDoubleToFloat.h; path = b3/B3ReduceDoubleToFloat.h; sourceTree = "<group>"; };
     3302                436E54511C468E5F00B5AF73 /* B3LegalizeMemoryOffsets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3LegalizeMemoryOffsets.cpp; path = b3/B3LegalizeMemoryOffsets.cpp; sourceTree = "<group>"; };
     3303                436E54521C468E5F00B5AF73 /* B3LegalizeMemoryOffsets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3LegalizeMemoryOffsets.h; path = b3/B3LegalizeMemoryOffsets.h; sourceTree = "<group>"; };
    33003304                43AB26C41C1A52F700D82AE6 /* B3MathExtras.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3MathExtras.cpp; path = b3/B3MathExtras.cpp; sourceTree = "<group>"; };
    33013305                43AB26C51C1A52F700D82AE6 /* B3MathExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3MathExtras.h; path = b3/B3MathExtras.h; sourceTree = "<group>"; };
     
    47594763                                0FEC85B51BE1462F0080FF74 /* B3InsertionSet.h */,
    47604764                                0FEC85B61BE1462F0080FF74 /* B3InsertionSetInlines.h */,
     4765                                436E54511C468E5F00B5AF73 /* B3LegalizeMemoryOffsets.cpp */,
     4766                                436E54521C468E5F00B5AF73 /* B3LegalizeMemoryOffsets.h */,
    47614767                                0F338E191BF286EA0013C88F /* B3LowerMacros.cpp */,
    47624768                                0F338E1A1BF286EA0013C88F /* B3LowerMacros.h */,
     
    80078013                                7E4EE7090EBB7963005934AA /* StructureChain.h in Headers */,
    80088014                                2AAAA31218BD49D100394CC8 /* StructureIDBlob.h in Headers */,
     8015                                436E54531C468E7400B5AF73 /* B3LegalizeMemoryOffsets.h in Headers */,
    80098016                                2AF7382D18BBBF92008A5A37 /* StructureIDTable.h in Headers */,
    80108017                                0FD2C92416D01EE900C7803F /* StructureInlines.h in Headers */,
     
    87098716                                0FEC850B1BDACDAC0080FF74 /* B3Commutativity.cpp in Sources */,
    87108717                                0FEC850D1BDACDAC0080FF74 /* B3Const32Value.cpp in Sources */,
     8718                                436E54541C468E7700B5AF73 /* B3LegalizeMemoryOffsets.cpp in Sources */,
    87118719                                0FEC850F1BDACDAC0080FF74 /* B3Const64Value.cpp in Sources */,
    87128720                                0FEC85111BDACDAC0080FF74 /* B3ConstDoubleValue.cpp in Sources */,
  • trunk/Source/JavaScriptCore/b3/B3Generate.cpp

    r194976 r195159  
    3333#include "AirInstInlines.h"
    3434#include "B3Common.h"
     35#include "B3LegalizeMemoryOffsets.h"
    3536#include "B3LowerMacros.h"
    3637#include "B3LowerMacrosAfterOptimizations.h"
     
    8687    lowerMacrosAfterOptimizations(procedure);
    8788
     89    legalizeMemoryOffsets(procedure);
     90
    8891    moveConstants(procedure);
    8992
  • trunk/Source/JavaScriptCore/b3/B3LowerToAir.cpp

    r195139 r195159  
    370370    Arg effectiveAddr(Value* address, int32_t offset, Arg::Width width)
    371371    {
    372         // B3 allows any memory operation to have a 32-bit offset. That's not how some architectures
    373         // work. We solve this by requiring a just-before-lowering phase that legalizes offsets.
    374         // FIXME: Implement such a legalization phase.
    375         // https://bugs.webkit.org/show_bug.cgi?id=152530
    376372        ASSERT(Arg::isValidAddrForm(offset, width));
    377373
  • trunk/Source/JavaScriptCore/b3/testb3.cpp

    r195139 r195159  
    137137}
    138138
     139void testLoadWithOffsetImpl(int32_t offset64, int32_t offset32)
     140{
     141    {
     142        Procedure proc;
     143        BasicBlock* root = proc.addBlock();
     144        int64_t x = -42;
     145        Value* base = root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0);
     146        root->appendNew<ControlValue>(
     147            proc, Return, Origin(),
     148            root->appendNew<MemoryValue>(
     149                proc, Load, Int64, Origin(),
     150                base,
     151                offset64));
     152
     153        char* address = reinterpret_cast<char*>(&x) - offset64;
     154        CHECK(compileAndRun<int64_t>(proc, address) == -42);
     155    }
     156    {
     157        Procedure proc;
     158        BasicBlock* root = proc.addBlock();
     159        int32_t x = -42;
     160        Value* base = root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0);
     161        root->appendNew<ControlValue>(
     162            proc, Return, Origin(),
     163            root->appendNew<MemoryValue>(
     164                proc, Load, Int32, Origin(),
     165                base,
     166                offset32));
     167
     168        char* address = reinterpret_cast<char*>(&x) - offset32;
     169        CHECK(compileAndRun<int32_t>(proc, address) == -42);
     170    }
     171}
     172
     173void testLoadOffsetImm9Max()
     174{
     175    testLoadWithOffsetImpl(255, 255);
     176}
     177
     178void testLoadOffsetImm9MaxPlusOne()
     179{
     180    testLoadWithOffsetImpl(256, 256);
     181}
     182
     183void testLoadOffsetImm9MaxPlusTwo()
     184{
     185    testLoadWithOffsetImpl(257, 257);
     186}
     187
     188void testLoadOffsetImm9Min()
     189{
     190    testLoadWithOffsetImpl(-256, -256);
     191}
     192
     193void testLoadOffsetImm9MinMinusOne()
     194{
     195    testLoadWithOffsetImpl(-257, -257);
     196}
     197
     198void testLoadOffsetScaledUnsignedImm12Max()
     199{
     200    testLoadWithOffsetImpl(32760, 16380);
     201}
     202
     203void testLoadOffsetScaledUnsignedOverImm12Max()
     204{
     205    testLoadWithOffsetImpl(32760, 32760);
     206    testLoadWithOffsetImpl(32761, 16381);
     207    testLoadWithOffsetImpl(32768, 16384);
     208}
     209
    139210void testArg(int argument)
    140211{
     
    93489419    RUN(test42());
    93499420    RUN(testLoad42());
     9421    RUN(testLoadOffsetImm9Max());
     9422    RUN(testLoadOffsetImm9MaxPlusOne());
     9423    RUN(testLoadOffsetImm9MaxPlusTwo());
     9424    RUN(testLoadOffsetImm9Min());
     9425    RUN(testLoadOffsetImm9MinMinusOne());
     9426    RUN(testLoadOffsetScaledUnsignedImm12Max());
     9427    RUN(testLoadOffsetScaledUnsignedOverImm12Max());
    93509428    RUN(testArg(43));
    93519429    RUN(testReturnConst64(5));
Note: See TracChangeset for help on using the changeset viewer.