Air needs a late register liveness phase that calls Special::reportUsedRegisters()
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Oct 2015 23:01:30 +0000 (23:01 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Oct 2015 23:01:30 +0000 (23:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150511

Reviewed by Saam Barati.

This change adds such a phase. In the process of writing it, I was reminded about the
glaring efficiency bugs in Air::Liveness and so I filed a bug and added FIXMEs.

* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/air/AirAllocateStack.cpp:
(JSC::B3::Air::allocateStack):
* b3/air/AirGenerate.cpp:
(JSC::B3::Air::generate):
* b3/air/AirReportUsedRegisters.cpp: Added.
(JSC::B3::Air::reportUsedRegisters):
* b3/air/AirReportUsedRegisters.h: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191845 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/b3/air/AirAllocateStack.cpp
Source/JavaScriptCore/b3/air/AirGenerate.cpp
Source/JavaScriptCore/b3/air/AirReportUsedRegisters.cpp [new file with mode: 0644]
Source/JavaScriptCore/b3/air/AirReportUsedRegisters.h [new file with mode: 0644]

index 81dfd1baf46d0749a10d2cbd081793946107e1f3..96a2c39c5f9d8848b7863de413d3fbfa07a46890 100644 (file)
@@ -1,3 +1,22 @@
+2015-10-31  Filip Pizlo  <fpizlo@apple.com>
+
+        Air needs a late register liveness phase that calls Special::reportUsedRegisters()
+        https://bugs.webkit.org/show_bug.cgi?id=150511
+
+        Reviewed by Saam Barati.
+
+        This change adds such a phase. In the process of writing it, I was reminded about the
+        glaring efficiency bugs in Air::Liveness and so I filed a bug and added FIXMEs.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * b3/air/AirAllocateStack.cpp:
+        (JSC::B3::Air::allocateStack):
+        * b3/air/AirGenerate.cpp:
+        (JSC::B3::Air::generate):
+        * b3/air/AirReportUsedRegisters.cpp: Added.
+        (JSC::B3::Air::reportUsedRegisters):
+        * b3/air/AirReportUsedRegisters.h: Added.
+
 2015-10-31  Brian Burg  <bburg@apple.com>
 
         Builtins generator should put WebCore-only wrappers in the per-builtin header
index 6892260ce4ad78a641320c6fb7ed506a64f59784..fca616e3eac73dfe2cfcb334557873818880b4a8 100644 (file)
                0F426A491460CBB700131F8F /* VirtualRegister.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F426A461460CBAB00131F8F /* VirtualRegister.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F426A4B1460CD6E00131F8F /* DataFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F426A4A1460CD6B00131F8F /* DataFormat.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F431738146BAC69007E3890 /* ListableHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F431736146BAC65007E3890 /* ListableHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               0F45703C1BE45F0A0062A629 /* AirReportUsedRegisters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F45703A1BE45F0A0062A629 /* AirReportUsedRegisters.cpp */; };
+               0F45703D1BE45F0A0062A629 /* AirReportUsedRegisters.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F45703B1BE45F0A0062A629 /* AirReportUsedRegisters.h */; };
                0F46808214BA572D00BFE272 /* JITExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F46808014BA572700BFE272 /* JITExceptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F46808314BA573100BFE272 /* JITExceptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F46807F14BA572700BFE272 /* JITExceptions.cpp */; };
                0F4680A314BA7F8D00BFE272 /* LLIntExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F46809E14BA7F8200BFE272 /* LLIntExceptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F426A461460CBAB00131F8F /* VirtualRegister.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualRegister.h; sourceTree = "<group>"; };
                0F426A4A1460CD6B00131F8F /* DataFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataFormat.h; sourceTree = "<group>"; };
                0F431736146BAC65007E3890 /* ListableHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListableHandler.h; sourceTree = "<group>"; };
+               0F45703A1BE45F0A0062A629 /* AirReportUsedRegisters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirReportUsedRegisters.cpp; path = b3/air/AirReportUsedRegisters.cpp; sourceTree = "<group>"; };
+               0F45703B1BE45F0A0062A629 /* AirReportUsedRegisters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirReportUsedRegisters.h; path = b3/air/AirReportUsedRegisters.h; sourceTree = "<group>"; };
                0F46807F14BA572700BFE272 /* JITExceptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITExceptions.cpp; sourceTree = "<group>"; };
                0F46808014BA572700BFE272 /* JITExceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITExceptions.h; sourceTree = "<group>"; };
                0F46809D14BA7F8200BFE272 /* LLIntExceptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLIntExceptions.cpp; path = llint/LLIntExceptions.cpp; sourceTree = "<group>"; };
                                264091FA1BE2FD4100684DB2 /* AirOpcode.opcodes */,
                                0FEC855E1BDACDC70080FF74 /* AirPhaseScope.cpp */,
                                0FEC855F1BDACDC70080FF74 /* AirPhaseScope.h */,
+                               0F45703A1BE45F0A0062A629 /* AirReportUsedRegisters.cpp */,
+                               0F45703B1BE45F0A0062A629 /* AirReportUsedRegisters.h */,
                                0FEC85601BDACDC70080FF74 /* AirRegisterPriority.cpp */,
                                0FEC85611BDACDC70080FF74 /* AirRegisterPriority.h */,
                                0FEC85621BDACDC70080FF74 /* AirSpecial.cpp */,
                                0FD8A32617D51F5700CA2C40 /* DFGOSREntrypointCreationPhase.h in Headers */,
                                0FC0976A1468A6F700CF2442 /* DFGOSRExit.h in Headers */,
                                0F235BEC17178E7300690C7F /* DFGOSRExitBase.h in Headers */,
+                               0F45703D1BE45F0A0062A629 /* AirReportUsedRegisters.h in Headers */,
                                0FFB921C16D02F110055A5DB /* DFGOSRExitCompilationInfo.h in Headers */,
                                0FEC85351BDACDAC0080FF74 /* B3StackSlotValue.h in Headers */,
                                0FC0977114693AF500CF2442 /* DFGOSRExitCompiler.h in Headers */,
                                62774DAA1B8D4B190006F05A /* FTLJSTailCall.cpp in Sources */,
                                0FB4FB731BC843140025CA5A /* FTLLazySlowPath.cpp in Sources */,
                                0F8F2B95172E04A0007DBDA5 /* FTLLink.cpp in Sources */,
+                               0F45703C1BE45F0A0062A629 /* AirReportUsedRegisters.cpp in Sources */,
                                0FCEFADF180738C000472CE4 /* FTLLocation.cpp in Sources */,
                                0FEA0A0F170513DB00BB722C /* FTLLowerDFGToLLVM.cpp in Sources */,
                                0FEC85001BDACDAC0080FF74 /* B3BasicBlock.cpp in Sources */,
index 7470d744a0a1a3d41982028558f9d40029ceb36a..bc902ef17ee767e3755657d17dc6d8389d0881b4 100644 (file)
@@ -141,6 +141,8 @@ void allocateStack(Code& code)
     }
 
     // Now we handle the anonymous slots.
+    // FIXME: We should tell Liveness to only track StackSlots.
+    // https://bugs.webkit.org/show_bug.cgi?id=150751
     Liveness<Arg> liveness(code);
     IndexMap<StackSlot, HashSet<StackSlot*>> interference(code.stackSlots().size());
     Vector<StackSlot*> slots;
index 155ebffc82492440890f863b49cd0209555edb6c..bed36f3b712b06c25087b64ede4a22549224fce7 100644 (file)
@@ -32,6 +32,7 @@
 #include "AirCode.h"
 #include "AirGenerationContext.h"
 #include "AirHandleCalleeSaves.h"
+#include "AirReportUsedRegisters.h"
 #include "AirSpillEverything.h"
 #include "AirValidate.h"
 #include "B3Common.h"
@@ -75,9 +76,7 @@ void generate(Code& code, CCallHelpers& jit)
     // FIXME: We should really have a code layout optimization here.
     // https://bugs.webkit.org/show_bug.cgi?id=150478
 
-    // FIXME: We need a late liveness analysis over registers to fill in the
-    // Special::reportUsedRegisters().
-    // https://bugs.webkit.org/show_bug.cgi?id=150511
+    reportUsedRegisters(code);
 
     if (shouldValidateIR())
         validate(code);
diff --git a/Source/JavaScriptCore/b3/air/AirReportUsedRegisters.cpp b/Source/JavaScriptCore/b3/air/AirReportUsedRegisters.cpp
new file mode 100644 (file)
index 0000000..12b2033
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2015 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 "AirReportUsedRegisters.h"
+
+#if ENABLE(B3_JIT)
+
+#include "AirCode.h"
+#include "AirInstInlines.h"
+#include "AirLiveness.h"
+#include "AirPhaseScope.h"
+
+namespace JSC { namespace B3 { namespace Air {
+
+void reportUsedRegisters(Code& code)
+{
+    PhaseScope phaseScope(code, "reportUsedRegisters");
+
+    // FIXME: We should tell liveness to only track Regs.
+    // https://bugs.webkit.org/show_bug.cgi?id=150751
+    Liveness<Tmp> liveness(code);
+
+    for (BasicBlock* block : code) {
+        Liveness<Tmp>::LocalCalc localCalc(liveness, block);
+
+        for (unsigned instIndex = block->size(); instIndex--;) {
+            Inst& inst = block->at(instIndex);
+            if (inst.hasSpecial()) {
+                RegisterSet registerSet;
+                for (Tmp tmp : localCalc.live()) {
+                    if (tmp.isReg())
+                        registerSet.set(tmp.reg());
+                }
+                inst.reportUsedRegisters(registerSet);
+            }
+            localCalc.execute(inst);
+        }
+    }
+}
+
+} } } // namespace JSC::B3::Air
+
+#endif // ENABLE(B3_JIT)
+
+
diff --git a/Source/JavaScriptCore/b3/air/AirReportUsedRegisters.h b/Source/JavaScriptCore/b3/air/AirReportUsedRegisters.h
new file mode 100644 (file)
index 0000000..ee424b3
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2015 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. 
+ */
+
+#ifndef AirReportUsedRegisters_h
+#define AirReportUsedRegisters_h
+
+#if ENABLE(B3_JIT)
+
+namespace JSC { namespace B3 { namespace Air {
+
+class Code;
+
+// Performs a liveness analysis over registers and reports the live registers to every Special.
+
+void reportUsedRegisters(Code&);
+
+} } } // namespace JSC::B3::Air
+
+#endif // ENABLE(B3_JIT)
+
+#endif // AirReportUsedRegisters_h
+