Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (196572 => 196573)
--- trunk/Source/_javascript_Core/ChangeLog 2016-02-15 08:39:58 UTC (rev 196572)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-02-15 09:12:45 UTC (rev 196573)
@@ -1,3 +1,26 @@
+2016-02-15 Benjamin Poulain <[email protected]>
+
+ [JSC] Improve the interface of Inst::shouldTryAliasingDef()
+ https://bugs.webkit.org/show_bug.cgi?id=154227
+
+ Reviewed by Andreas Kling.
+
+ Using Optional<> instead of a bool+reference looks cleaner
+ at the call sites.
+
+ * b3/B3CheckSpecial.cpp:
+ (JSC::B3::CheckSpecial::shouldTryAliasingDef):
+ * b3/B3CheckSpecial.h:
+ * b3/air/AirCustom.h:
+ (JSC::B3::Air::PatchCustom::shouldTryAliasingDef):
+ * b3/air/AirInst.h:
+ * b3/air/AirInstInlines.h:
+ (JSC::B3::Air::Inst::shouldTryAliasingDef):
+ * b3/air/AirIteratedRegisterCoalescing.cpp:
+ * b3/air/AirSpecial.cpp:
+ (JSC::B3::Air::Special::shouldTryAliasingDef):
+ * b3/air/AirSpecial.h:
+
2016-02-14 Brian Burg <[email protected]>
WKAutomationDelegate's requestAutomationSession should take a suggested session identifier
Modified: trunk/Source/_javascript_Core/b3/B3CheckSpecial.cpp (196572 => 196573)
--- trunk/Source/_javascript_Core/b3/B3CheckSpecial.cpp 2016-02-15 08:39:58 UTC (rev 196572)
+++ trunk/Source/_javascript_Core/b3/B3CheckSpecial.cpp 2016-02-15 09:12:45 UTC (rev 196573)
@@ -130,13 +130,11 @@
return admitsStackImpl(numB3Args(inst), m_numCheckArgs + 1, inst, argIndex);
}
-bool CheckSpecial::shouldTryAliasingDef(Inst& inst, unsigned& defIndex)
+Optional<unsigned> CheckSpecial::shouldTryAliasingDef(Inst& inst)
{
- if (hiddenBranch(inst).shouldTryAliasingDef(defIndex)) {
- defIndex += 1;
- return true;
- }
- return false;
+ if (Optional<unsigned> branchDef = hiddenBranch(inst).shouldTryAliasingDef())
+ return *branchDef + 1;
+ return Nullopt;
}
CCallHelpers::Jump CheckSpecial::generate(Inst& inst, CCallHelpers& jit, GenerationContext& context)
Modified: trunk/Source/_javascript_Core/b3/B3CheckSpecial.h (196572 => 196573)
--- trunk/Source/_javascript_Core/b3/B3CheckSpecial.h 2016-02-15 08:39:58 UTC (rev 196572)
+++ trunk/Source/_javascript_Core/b3/B3CheckSpecial.h 2016-02-15 09:12:45 UTC (rev 196573)
@@ -126,7 +126,7 @@
void forEachArg(Air::Inst&, const ScopedLambda<Air::Inst::EachArgCallback>&) override;
bool isValid(Air::Inst&) override;
bool admitsStack(Air::Inst&, unsigned argIndex) override;
- bool shouldTryAliasingDef(Air::Inst&, unsigned& defIndex) override;
+ Optional<unsigned> shouldTryAliasingDef(Air::Inst&) override;
// NOTE: the generate method will generate the hidden branch and then register a LatePath that
// generates the stackmap. Super crazy dude!
Modified: trunk/Source/_javascript_Core/b3/air/AirCustom.h (196572 => 196573)
--- trunk/Source/_javascript_Core/b3/air/AirCustom.h 2016-02-15 08:39:58 UTC (rev 196572)
+++ trunk/Source/_javascript_Core/b3/air/AirCustom.h 2016-02-15 09:12:45 UTC (rev 196573)
@@ -80,9 +80,9 @@
return inst.args[0].special()->admitsStack(inst, argIndex);
}
- static bool shouldTryAliasingDef(Inst& inst, unsigned& defIndex)
+ static Optional<unsigned> shouldTryAliasingDef(Inst& inst)
{
- return inst.args[0].special()->shouldTryAliasingDef(inst, defIndex);
+ return inst.args[0].special()->shouldTryAliasingDef(inst);
}
static bool hasNonArgNonControlEffects(Inst& inst)
Modified: trunk/Source/_javascript_Core/b3/air/AirInst.h (196572 => 196573)
--- trunk/Source/_javascript_Core/b3/air/AirInst.h 2016-02-15 08:39:58 UTC (rev 196572)
+++ trunk/Source/_javascript_Core/b3/air/AirInst.h 2016-02-15 09:12:45 UTC (rev 196573)
@@ -180,11 +180,13 @@
// case being fall-through. This function is auto-generated by opcode_generator.rb.
CCallHelpers::Jump generate(CCallHelpers&, GenerationContext&);
- // Returns true if the register allocator should attempt to alias the arguments with the destination
- // for this instruction.
- // If the method returns true, defIndex is set to the index of the destination argument. The indices
- // (defIndex - 1) and (defIndex - 2) are the one to alias to defIndex.
- bool shouldTryAliasingDef(unsigned& defIndex);
+ // If source arguments benefits from being aliased to a destination argument,
+ // this return the index of the destination argument.
+ // The source are assumed to be at (index - 1) and (index - 2)
+ // For example,
+ // Add Tmp1, Tmp2, Tmp3
+ // returns 2 if 0 and 1 benefit from aliasing to Tmp3.
+ Optional<unsigned> shouldTryAliasingDef();
void dump(PrintStream&) const;
Modified: trunk/Source/_javascript_Core/b3/air/AirInstInlines.h (196572 => 196573)
--- trunk/Source/_javascript_Core/b3/air/AirInstInlines.h 2016-02-15 08:39:58 UTC (rev 196572)
+++ trunk/Source/_javascript_Core/b3/air/AirInstInlines.h 2016-02-15 09:12:45 UTC (rev 196573)
@@ -164,10 +164,10 @@
return admitsStack(&arg - &args[0]);
}
-inline bool Inst::shouldTryAliasingDef(unsigned& defIndex)
+inline Optional<unsigned> Inst::shouldTryAliasingDef()
{
if (!isX86())
- return false;
+ return Nullopt;
switch (opcode) {
case Add32:
@@ -188,24 +188,20 @@
case MulFloat:
case XorDouble:
case XorFloat:
- if (args.size() == 3) {
- defIndex = 2;
- return true;
- }
+ if (args.size() == 3)
+ return 2;
break;
case BranchAdd32:
case BranchAdd64:
- if (args.size() == 4) {
- defIndex = 3;
- return true;
- }
+ if (args.size() == 4)
+ return 3;
break;
case Patch:
- return PatchCustom::shouldTryAliasingDef(*this, defIndex);
+ return PatchCustom::shouldTryAliasingDef(*this);
default:
break;
}
- return false;
+ return Nullopt;
}
inline bool isShiftValid(const Inst& inst)
Modified: trunk/Source/_javascript_Core/b3/air/AirIteratedRegisterCoalescing.cpp (196572 => 196573)
--- trunk/Source/_javascript_Core/b3/air/AirIteratedRegisterCoalescing.cpp 2016-02-15 08:39:58 UTC (rev 196572)
+++ trunk/Source/_javascript_Core/b3/air/AirIteratedRegisterCoalescing.cpp 2016-02-15 09:12:45 UTC (rev 196573)
@@ -992,11 +992,10 @@
m_worklistMoves.startAddingLowPriorityMoves();
for (BasicBlock* block : m_code) {
for (Inst& inst : *block) {
- unsigned defArgIndex = 0;
- if (inst.shouldTryAliasingDef(defArgIndex)) {
- Arg op1 = inst.args[defArgIndex - 2];
- Arg op2 = inst.args[defArgIndex - 1];
- Arg dest = inst.args[defArgIndex];
+ if (Optional<unsigned> defArgIndex = inst.shouldTryAliasingDef()) {
+ Arg op1 = inst.args[*defArgIndex - 2];
+ Arg op2 = inst.args[*defArgIndex - 1];
+ Arg dest = inst.args[*defArgIndex];
if (op1 == dest || op2 == dest)
continue;
Modified: trunk/Source/_javascript_Core/b3/air/AirSpecial.cpp (196572 => 196573)
--- trunk/Source/_javascript_Core/b3/air/AirSpecial.cpp 2016-02-15 08:39:58 UTC (rev 196572)
+++ trunk/Source/_javascript_Core/b3/air/AirSpecial.cpp 2016-02-15 09:12:45 UTC (rev 196573)
@@ -50,9 +50,9 @@
return out.toCString();
}
-bool Special::shouldTryAliasingDef(Inst&, unsigned&)
+Optional<unsigned> Special::shouldTryAliasingDef(Inst&)
{
- return false;
+ return Nullopt;
}
bool Special::hasNonArgNonControlEffects()
Modified: trunk/Source/_javascript_Core/b3/air/AirSpecial.h (196572 => 196573)
--- trunk/Source/_javascript_Core/b3/air/AirSpecial.h 2016-02-15 08:39:58 UTC (rev 196572)
+++ trunk/Source/_javascript_Core/b3/air/AirSpecial.h 2016-02-15 09:12:45 UTC (rev 196573)
@@ -56,7 +56,7 @@
virtual void forEachArg(Inst&, const ScopedLambda<Inst::EachArgCallback>&) = 0;
virtual bool isValid(Inst&) = 0;
virtual bool admitsStack(Inst&, unsigned argIndex) = 0;
- virtual bool shouldTryAliasingDef(Inst&, unsigned& defIndex);
+ virtual Optional<unsigned> shouldTryAliasingDef(Inst&);
// This gets called on for each Inst that uses this Special. Note that there is no way to
// guarantee that a Special gets used from just one Inst, because Air might taildup late. So,