Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (214837 => 214838)
--- trunk/Source/_javascript_Core/ChangeLog 2017-04-03 21:03:52 UTC (rev 214837)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-04-03 21:07:01 UTC (rev 214838)
@@ -1,5 +1,49 @@
2017-04-03 Filip Pizlo <fpi...@apple.com>
+ Move the Liveness<> adapters from AirLiveness.h to AirLivenessAdapter.h.
+
+ Rubber stamped by Keith Miller.
+
+ This will make it easier to write other code that uses those adapters.
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * b3/air/AirLiveness.h:
+ (JSC::B3::Air::LivenessAdapter::LivenessAdapter): Deleted.
+ (JSC::B3::Air::LivenessAdapter::blockSize): Deleted.
+ (JSC::B3::Air::LivenessAdapter::forEachUse): Deleted.
+ (JSC::B3::Air::LivenessAdapter::forEachDef): Deleted.
+ (JSC::B3::Air::TmpLivenessAdapter::TmpLivenessAdapter): Deleted.
+ (JSC::B3::Air::TmpLivenessAdapter::numIndices): Deleted.
+ (JSC::B3::Air::TmpLivenessAdapter::acceptsBank): Deleted.
+ (JSC::B3::Air::TmpLivenessAdapter::acceptsRole): Deleted.
+ (JSC::B3::Air::TmpLivenessAdapter::valueToIndex): Deleted.
+ (JSC::B3::Air::TmpLivenessAdapter::indexToValue): Deleted.
+ (JSC::B3::Air::StackSlotLivenessAdapter::StackSlotLivenessAdapter): Deleted.
+ (JSC::B3::Air::StackSlotLivenessAdapter::numIndices): Deleted.
+ (JSC::B3::Air::StackSlotLivenessAdapter::acceptsBank): Deleted.
+ (JSC::B3::Air::StackSlotLivenessAdapter::acceptsRole): Deleted.
+ (JSC::B3::Air::StackSlotLivenessAdapter::valueToIndex): Deleted.
+ (JSC::B3::Air::StackSlotLivenessAdapter::indexToValue): Deleted.
+ * b3/air/AirLivenessAdapter.h: Added.
+ (JSC::B3::Air::LivenessAdapter::LivenessAdapter):
+ (JSC::B3::Air::LivenessAdapter::blockSize):
+ (JSC::B3::Air::LivenessAdapter::forEachUse):
+ (JSC::B3::Air::LivenessAdapter::forEachDef):
+ (JSC::B3::Air::TmpLivenessAdapter::TmpLivenessAdapter):
+ (JSC::B3::Air::TmpLivenessAdapter::numIndices):
+ (JSC::B3::Air::TmpLivenessAdapter::acceptsBank):
+ (JSC::B3::Air::TmpLivenessAdapter::acceptsRole):
+ (JSC::B3::Air::TmpLivenessAdapter::valueToIndex):
+ (JSC::B3::Air::TmpLivenessAdapter::indexToValue):
+ (JSC::B3::Air::StackSlotLivenessAdapter::StackSlotLivenessAdapter):
+ (JSC::B3::Air::StackSlotLivenessAdapter::numIndices):
+ (JSC::B3::Air::StackSlotLivenessAdapter::acceptsBank):
+ (JSC::B3::Air::StackSlotLivenessAdapter::acceptsRole):
+ (JSC::B3::Air::StackSlotLivenessAdapter::valueToIndex):
+ (JSC::B3::Air::StackSlotLivenessAdapter::indexToValue):
+
+2017-04-03 Filip Pizlo <fpi...@apple.com>
+
WTF::Liveness should have an API that focuses on actions at instruction boundaries
https://bugs.webkit.org/show_bug.cgi?id=170407
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (214837 => 214838)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2017-04-03 21:03:52 UTC (rev 214837)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2017-04-03 21:07:01 UTC (rev 214838)
@@ -118,6 +118,7 @@
0F15CD231BA5F9860031FFD3 /* PutByIdFlags.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15CD211BA5F9860031FFD3 /* PutByIdFlags.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F15F15F14B7A73E005DE37D /* CommonSlowPaths.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F1725FF1B48719A00AC3A55 /* DFGMinifiedGraph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F1725FE1B48719A00AC3A55 /* DFGMinifiedGraph.cpp */; };
+ 0F1829691E92EE54005B1EA8 /* AirLivenessAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F1829681E92EE51005B1EA8 /* AirLivenessAdapter.h */; };
0F18D3CF1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F18D3CD1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.cpp */; };
0F18D3D01B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F18D3CE1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h */; };
0F190CAC189D82F6000AE5F0 /* ProfilerJettisonReason.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F190CAA189D82F6000AE5F0 /* ProfilerJettisonReason.cpp */; };
@@ -2652,6 +2653,7 @@
0F15CD211BA5F9860031FFD3 /* PutByIdFlags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PutByIdFlags.h; sourceTree = "<group>"; };
0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonSlowPaths.h; sourceTree = "<group>"; };
0F1725FE1B48719A00AC3A55 /* DFGMinifiedGraph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGMinifiedGraph.cpp; path = dfg/DFGMinifiedGraph.cpp; sourceTree = "<group>"; };
+ 0F1829681E92EE51005B1EA8 /* AirLivenessAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirLivenessAdapter.h; path = b3/air/AirLivenessAdapter.h; sourceTree = "<group>"; };
0F18D3CD1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGAdaptiveStructureWatchpoint.cpp; path = dfg/DFGAdaptiveStructureWatchpoint.cpp; sourceTree = "<group>"; };
0F18D3CE1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAdaptiveStructureWatchpoint.h; path = dfg/DFGAdaptiveStructureWatchpoint.h; sourceTree = "<group>"; };
0F190CAA189D82F6000AE5F0 /* ProfilerJettisonReason.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ProfilerJettisonReason.cpp; path = profiler/ProfilerJettisonReason.cpp; sourceTree = "<group>"; };
@@ -5610,6 +5612,7 @@
0FDF67D41D9DC43E001B9825 /* AirKind.cpp */,
0FDF67D51D9DC43E001B9825 /* AirKind.h */,
2684D4371C00161C0081D663 /* AirLiveness.h */,
+ 0F1829681E92EE51005B1EA8 /* AirLivenessAdapter.h */,
0FE34C171C4B39AE0003A512 /* AirLogRegisterPressure.cpp */,
0FE34C181C4B39AE0003A512 /* AirLogRegisterPressure.h */,
0F6183251C45BF070072450B /* AirLowerAfterRegAlloc.cpp */,
@@ -9110,6 +9113,7 @@
0FB5467B14F5C7E1002C2989 /* MethodOfGettingAValueProfile.h in Headers */,
7C008CE7187631B600955C24 /* Microtask.h in Headers */,
86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */,
+ 0F1829691E92EE54005B1EA8 /* AirLivenessAdapter.h in Headers */,
C4703CD7192844CC0013FBEA /* models.py in Headers */,
E3794E761B77EB97005543AE /* ModuleAnalyzer.h in Headers */,
E355F3531B7DC85300C50DC5 /* ModuleLoaderPrototype.h in Headers */,
Modified: trunk/Source/_javascript_Core/b3/air/AirLiveness.h (214837 => 214838)
--- trunk/Source/_javascript_Core/b3/air/AirLiveness.h 2017-04-03 21:03:52 UTC (rev 214837)
+++ trunk/Source/_javascript_Core/b3/air/AirLiveness.h 2017-04-03 21:07:01 UTC (rev 214838)
@@ -27,124 +27,12 @@
#if ENABLE(B3_JIT)
-#include "AirBasicBlock.h"
-#include "AirCFG.h"
-#include "AirCode.h"
-#include "AirInstInlines.h"
-#include "AirStackSlot.h"
-#include "AirTmpInlines.h"
+#include "AirLivenessAdapter.h"
#include <wtf/Liveness.h>
namespace JSC { namespace B3 { namespace Air {
template<typename Adapter>
-struct LivenessAdapter {
- typedef Air::CFG CFG;
-
- LivenessAdapter(Code& code)
- : code(code)
- {
- }
-
- unsigned blockSize(BasicBlock* block)
- {
- return block->size();
- }
-
- template<typename Func>
- void forEachUse(BasicBlock* block, size_t instBoundaryIndex, const Func& func)
- {
- if (Inst* prevInst = block->get(instBoundaryIndex - 1)) {
- prevInst->forEach<typename Adapter::Thing>(
- [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
- if (Arg::isLateUse(role)
- && Adapter::acceptsBank(bank)
- && Adapter::acceptsRole(role))
- func(Adapter::valueToIndex(thing));
- });
- }
-
- if (Inst* nextInst = block->get(instBoundaryIndex)) {
- nextInst->forEach<typename Adapter::Thing>(
- [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
- if (Arg::isEarlyUse(role)
- && Adapter::acceptsBank(bank)
- && Adapter::acceptsRole(role))
- func(Adapter::valueToIndex(thing));
- });
- }
- }
-
- template<typename Func>
- void forEachDef(BasicBlock* block, size_t instBoundaryIndex, const Func& func)
- {
- if (Inst* prevInst = block->get(instBoundaryIndex - 1)) {
- prevInst->forEach<typename Adapter::Thing>(
- [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
- if (Arg::isLateDef(role)
- && Adapter::acceptsBank(bank)
- && Adapter::acceptsRole(role))
- func(Adapter::valueToIndex(thing));
- });
- }
-
- if (Inst* nextInst = block->get(instBoundaryIndex)) {
- nextInst->forEach<typename Adapter::Thing>(
- [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
- if (Arg::isEarlyDef(role)
- && Adapter::acceptsBank(bank)
- && Adapter::acceptsRole(role))
- func(Adapter::valueToIndex(thing));
- });
- }
- }
-
- Code& code;
-};
-
-template<Bank adapterBank, Arg::Temperature minimumTemperature = Arg::Cold>
-struct TmpLivenessAdapter : LivenessAdapter<TmpLivenessAdapter<adapterBank, minimumTemperature>> {
- typedef LivenessAdapter<TmpLivenessAdapter<adapterBank, minimumTemperature>> Base;
-
- static constexpr const char* name = "TmpLiveness";
- typedef Tmp Thing;
-
- TmpLivenessAdapter(Code& code)
- : Base(code)
- {
- }
-
- unsigned numIndices()
- {
- unsigned numTmps = Base::code.numTmps(adapterBank);
- return AbsoluteTmpMapper<adapterBank>::absoluteIndex(numTmps);
- }
- static bool acceptsBank(Bank bank) { return bank == adapterBank; }
- static bool acceptsRole(Arg::Role role) { return Arg::temperature(role) >= minimumTemperature; }
- static unsigned valueToIndex(Tmp tmp) { return AbsoluteTmpMapper<adapterBank>::absoluteIndex(tmp); }
- static Tmp indexToValue(unsigned index) { return AbsoluteTmpMapper<adapterBank>::tmpFromAbsoluteIndex(index); }
-};
-
-struct StackSlotLivenessAdapter : LivenessAdapter<StackSlotLivenessAdapter> {
- static constexpr const char* name = "StackSlotLiveness";
- typedef StackSlot* Thing;
-
- StackSlotLivenessAdapter(Code& code)
- : LivenessAdapter(code)
- {
- }
-
- unsigned numIndices()
- {
- return code.stackSlots().size();
- }
- static bool acceptsBank(Bank) { return true; }
- static bool acceptsRole(Arg::Role) { return true; }
- static unsigned valueToIndex(StackSlot* stackSlot) { return stackSlot->index(); }
- StackSlot* indexToValue(unsigned index) { return code.stackSlots()[index]; }
-};
-
-template<typename Adapter>
class Liveness : public WTF::Liveness<Adapter> {
public:
Liveness(Code& code)
Added: trunk/Source/_javascript_Core/b3/air/AirLivenessAdapter.h (0 => 214838)
--- trunk/Source/_javascript_Core/b3/air/AirLivenessAdapter.h (rev 0)
+++ trunk/Source/_javascript_Core/b3/air/AirLivenessAdapter.h 2017-04-03 21:07:01 UTC (rev 214838)
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2015-2017 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.
+ */
+
+#pragma once
+
+#if ENABLE(B3_JIT)
+
+#include "AirBasicBlock.h"
+#include "AirCFG.h"
+#include "AirCode.h"
+#include "AirInstInlines.h"
+#include "AirStackSlot.h"
+#include "AirTmpInlines.h"
+
+namespace JSC { namespace B3 { namespace Air {
+
+template<typename Adapter>
+struct LivenessAdapter {
+ typedef Air::CFG CFG;
+
+ LivenessAdapter(Code& code)
+ : code(code)
+ {
+ }
+
+ unsigned blockSize(BasicBlock* block)
+ {
+ return block->size();
+ }
+
+ template<typename Func>
+ void forEachUse(BasicBlock* block, size_t instBoundaryIndex, const Func& func)
+ {
+ if (Inst* prevInst = block->get(instBoundaryIndex - 1)) {
+ prevInst->forEach<typename Adapter::Thing>(
+ [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
+ if (Arg::isLateUse(role)
+ && Adapter::acceptsBank(bank)
+ && Adapter::acceptsRole(role))
+ func(Adapter::valueToIndex(thing));
+ });
+ }
+
+ if (Inst* nextInst = block->get(instBoundaryIndex)) {
+ nextInst->forEach<typename Adapter::Thing>(
+ [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
+ if (Arg::isEarlyUse(role)
+ && Adapter::acceptsBank(bank)
+ && Adapter::acceptsRole(role))
+ func(Adapter::valueToIndex(thing));
+ });
+ }
+ }
+
+ template<typename Func>
+ void forEachDef(BasicBlock* block, size_t instBoundaryIndex, const Func& func)
+ {
+ if (Inst* prevInst = block->get(instBoundaryIndex - 1)) {
+ prevInst->forEach<typename Adapter::Thing>(
+ [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
+ if (Arg::isLateDef(role)
+ && Adapter::acceptsBank(bank)
+ && Adapter::acceptsRole(role))
+ func(Adapter::valueToIndex(thing));
+ });
+ }
+
+ if (Inst* nextInst = block->get(instBoundaryIndex)) {
+ nextInst->forEach<typename Adapter::Thing>(
+ [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
+ if (Arg::isEarlyDef(role)
+ && Adapter::acceptsBank(bank)
+ && Adapter::acceptsRole(role))
+ func(Adapter::valueToIndex(thing));
+ });
+ }
+ }
+
+ Code& code;
+};
+
+template<Bank adapterBank, Arg::Temperature minimumTemperature = Arg::Cold>
+struct TmpLivenessAdapter : LivenessAdapter<TmpLivenessAdapter<adapterBank, minimumTemperature>> {
+ typedef LivenessAdapter<TmpLivenessAdapter<adapterBank, minimumTemperature>> Base;
+
+ static constexpr const char* name = "TmpLiveness";
+ typedef Tmp Thing;
+
+ TmpLivenessAdapter(Code& code)
+ : Base(code)
+ {
+ }
+
+ unsigned numIndices()
+ {
+ unsigned numTmps = Base::code.numTmps(adapterBank);
+ return AbsoluteTmpMapper<adapterBank>::absoluteIndex(numTmps);
+ }
+ static bool acceptsBank(Bank bank) { return bank == adapterBank; }
+ static bool acceptsRole(Arg::Role role) { return Arg::temperature(role) >= minimumTemperature; }
+ static unsigned valueToIndex(Tmp tmp) { return AbsoluteTmpMapper<adapterBank>::absoluteIndex(tmp); }
+ static Tmp indexToValue(unsigned index) { return AbsoluteTmpMapper<adapterBank>::tmpFromAbsoluteIndex(index); }
+};
+
+struct StackSlotLivenessAdapter : LivenessAdapter<StackSlotLivenessAdapter> {
+ static constexpr const char* name = "StackSlotLiveness";
+ typedef StackSlot* Thing;
+
+ StackSlotLivenessAdapter(Code& code)
+ : LivenessAdapter(code)
+ {
+ }
+
+ unsigned numIndices()
+ {
+ return code.stackSlots().size();
+ }
+ static bool acceptsBank(Bank) { return true; }
+ static bool acceptsRole(Arg::Role) { return true; }
+ static unsigned valueToIndex(StackSlot* stackSlot) { return stackSlot->index(); }
+ StackSlot* indexToValue(unsigned index) { return code.stackSlots()[index]; }
+};
+
+} } } // namespace JSC::B3::Air
+
+#endif // ENABLE(B3_JIT)
+