Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (183524 => 183525)
--- trunk/Source/_javascript_Core/ChangeLog 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-04-29 03:34:43 UTC (rev 183525)
@@ -1,3 +1,42 @@
+2015-04-28 Filip Pizlo <[email protected]>
+
+ FTL should fully support Switch (it currently lacks the SwitchString variant)
+ https://bugs.webkit.org/show_bug.cgi?id=144348
+
+ Reviewed by Benjamin Poulain.
+
+ This adds SwitchString support to the FTL. This is already tested by switch microbenchmarks
+ in LayoutTests/js/regress.
+
+ * dfg/DFGCommon.cpp:
+ (JSC::DFG::stringLessThan):
+ * dfg/DFGCommon.h:
+ * dfg/DFGOperations.cpp:
+ * dfg/DFGOperations.h:
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::StringSwitchCase::operator<): Deleted.
+ * dfg/DFGSpeculativeJIT.h:
+ (JSC::DFG::SpeculativeJIT::StringSwitchCase::operator<):
+ * ftl/FTLCapabilities.cpp:
+ (JSC::FTL::canCompile):
+ * ftl/FTLIntrinsicRepository.h:
+ * ftl/FTLLowerDFGToLLVM.cpp:
+ (JSC::FTL::LowerDFGToLLVM::compileSwitch):
+ (JSC::FTL::LowerDFGToLLVM::switchString):
+ (JSC::FTL::LowerDFGToLLVM::StringSwitchCase::StringSwitchCase):
+ (JSC::FTL::LowerDFGToLLVM::StringSwitchCase::operator<):
+ (JSC::FTL::LowerDFGToLLVM::CharacterCase::CharacterCase):
+ (JSC::FTL::LowerDFGToLLVM::CharacterCase::operator<):
+ (JSC::FTL::LowerDFGToLLVM::switchStringRecurse):
+ (JSC::FTL::LowerDFGToLLVM::switchStringSlow):
+ (JSC::FTL::LowerDFGToLLVM::appendOSRExit):
+ * ftl/FTLOutput.cpp:
+ (JSC::FTL::Output::check):
+ * ftl/FTLOutput.h:
+ * ftl/FTLWeight.h:
+ (JSC::FTL::Weight::inverse):
+ * jit/JITOperations.h:
+
2015-04-28 Michael Catanzaro <[email protected]>
Fully replace ENABLE_LLINT_C_LOOP with ENABLE_JIT
Modified: trunk/Source/_javascript_Core/dfg/DFGCommon.cpp (183524 => 183525)
--- trunk/Source/_javascript_Core/dfg/DFGCommon.cpp 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/dfg/DFGCommon.cpp 2015-04-29 03:34:43 UTC (rev 183525)
@@ -46,6 +46,17 @@
return crashLock.isLocked();
}
+bool stringLessThan(StringImpl& a, StringImpl& b)
+{
+ unsigned minLength = std::min(a.length(), b.length());
+ for (unsigned i = 0; i < minLength; ++i) {
+ if (a[i] == b[i])
+ continue;
+ return a[i] < b[i];
+ }
+ return a.length() < b.length();
+}
+
} } // namespace JSC::DFG
namespace WTF {
Modified: trunk/Source/_javascript_Core/dfg/DFGCommon.h (183524 => 183525)
--- trunk/Source/_javascript_Core/dfg/DFGCommon.h 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/dfg/DFGCommon.h 2015-04-29 03:34:43 UTC (rev 183525)
@@ -297,6 +297,10 @@
unsigned index;
};
+// A less-than operator for strings that is useful for generating string switches. Sorts by <
+// relation on characters. Ensures that if a is a prefix of b, then a < b.
+bool stringLessThan(StringImpl& a, StringImpl& b);
+
} } // namespace JSC::DFG
namespace WTF {
Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (183524 => 183525)
--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2015-04-29 03:34:43 UTC (rev 183525)
@@ -1077,6 +1077,14 @@
return static_cast<char*>(exec->codeBlock()->stringSwitchJumpTable(tableIndex).ctiForValue(string->value(exec).impl()).executableAddress());
}
+int32_t JIT_OPERATION operationSwitchStringAndGetBranchOffset(ExecState* exec, size_t tableIndex, JSString* string)
+{
+ VM& vm = exec->vm();
+ NativeCallFrameTracer tracer(&vm, exec);
+
+ return exec->codeBlock()->stringSwitchJumpTable(tableIndex).offsetForValue(string->value(exec).impl(), std::numeric_limits<int32_t>::min());
+}
+
void JIT_OPERATION operationNotifyWrite(ExecState* exec, WatchpointSet* set)
{
VM& vm = exec->vm();
Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.h (183524 => 183525)
--- trunk/Source/_javascript_Core/dfg/DFGOperations.h 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.h 2015-04-29 03:34:43 UTC (rev 183525)
@@ -127,6 +127,7 @@
JSCell* JIT_OPERATION operationMakeRope3(ExecState*, JSString*, JSString*, JSString*);
char* JIT_OPERATION operationFindSwitchImmTargetForDouble(ExecState*, EncodedJSValue, size_t tableIndex);
char* JIT_OPERATION operationSwitchString(ExecState*, size_t tableIndex, JSString*);
+int32_t JIT_OPERATION operationSwitchStringAndGetBranchOffset(ExecState*, size_t tableIndex, JSString*);
void JIT_OPERATION operationNotifyWrite(ExecState*, WatchpointSet*);
void JIT_OPERATION operationThrowStackOverflowForVarargs(ExecState*) WTF_INTERNAL;
int32_t JIT_OPERATION operationSizeOfVarargs(ExecState*, EncodedJSValue arguments, int32_t firstVarArgOffset);
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (183524 => 183525)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2015-04-29 03:34:43 UTC (rev 183525)
@@ -5634,18 +5634,6 @@
}
}
-bool SpeculativeJIT::StringSwitchCase::operator<(
- const SpeculativeJIT::StringSwitchCase& other) const
-{
- unsigned minLength = std::min(string->length(), other.string->length());
- for (unsigned i = 0; i < minLength; ++i) {
- if (string->at(i) == other.string->at(i))
- continue;
- return string->at(i) < other.string->at(i);
- }
- return string->length() < other.string->length();
-}
-
namespace {
struct CharacterCase {
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h (183524 => 183525)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2015-04-29 03:34:43 UTC (rev 183525)
@@ -2115,7 +2115,10 @@
{
}
- bool operator<(const StringSwitchCase& other) const;
+ bool operator<(const StringSwitchCase& other) const
+ {
+ return stringLessThan(*string, *other.string);
+ }
StringImpl* string;
BasicBlock* target;
Modified: trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp (183524 => 183525)
--- trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp 2015-04-29 03:34:43 UTC (rev 183525)
@@ -188,6 +188,7 @@
case PhantomClonedArguments:
case GetMyArgumentByVal:
case ForwardVarargs:
+ case Switch:
// These are OK.
break;
case Identity:
@@ -350,16 +351,6 @@
if (node->isBinaryUseKind(UntypedUse))
break;
return CannotCompile;
- case Switch:
- switch (node->switchData()->kind) {
- case SwitchImm:
- case SwitchChar:
- case SwitchCell:
- break;
- default:
- return CannotCompile;
- }
- break;
default:
// Don't know how to handle anything else.
return CannotCompile;
Modified: trunk/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h (183524 => 183525)
--- trunk/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h 2015-04-29 03:34:43 UTC (rev 183525)
@@ -112,7 +112,8 @@
macro(V_JITOperation_Z, functionType(voidType, int32)) \
macro(Z_JITOperation_D, functionType(int32, doubleType)) \
macro(Z_JITOperation_EC, functionType(int32, intPtr, intPtr)) \
- macro(Z_JITOperation_EJZ, functionType(int32, intPtr, int64, int32))
+ macro(Z_JITOperation_EJZ, functionType(int32, intPtr, int64, int32)) \
+ macro(Z_JITOperation_ESJss, functionType(int32, intPtr, intPtr, int64)) \
class IntrinsicRepository : public CommonValues {
public:
Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp (183524 => 183525)
--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp 2015-04-29 03:34:43 UTC (rev 183525)
@@ -4439,7 +4439,54 @@
}
case SwitchString: {
- DFG_CRASH(m_graph, m_node, "Unimplemented");
+ switch (m_node->child1().useKind()) {
+ case StringIdentUse: {
+ LValue stringImpl = lowStringIdent(m_node->child1());
+
+ Vector<SwitchCase> cases;
+ for (unsigned i = 0; i < data->cases.size(); ++i) {
+ LValue value = m_out.constIntPtr(data->cases[i].value.stringImpl());
+ LBasicBlock block = lowBlock(data->cases[i].target.block);
+ Weight weight = Weight(data->cases[i].target.count);
+ cases.append(SwitchCase(value, block, weight));
+ }
+
+ m_out.switchInstruction(
+ stringImpl, cases, lowBlock(data->fallThrough.block),
+ Weight(data->fallThrough.count));
+ return;
+ }
+
+ case StringUse: {
+ switchString(data, lowString(m_node->child1()));
+ return;
+ }
+
+ case UntypedUse: {
+ LValue value = lowJSValue(m_node->child1());
+
+ LBasicBlock isCellBlock = FTL_NEW_BLOCK(m_out, ("Switch/SwitchString Untyped cell case"));
+ LBasicBlock isStringBlock = FTL_NEW_BLOCK(m_out, ("Switch/SwitchString Untyped string case"));
+
+ m_out.branch(
+ isCell(value), unsure(isCellBlock), unsure(lowBlock(data->fallThrough.block)));
+
+ LBasicBlock lastNext = m_out.appendTo(isCellBlock, isStringBlock);
+
+ m_out.branch(
+ isString(value),
+ unsure(isStringBlock), unsure(lowBlock(data->fallThrough.block)));
+
+ m_out.appendTo(isStringBlock, lastNext);
+
+ switchString(data, value);
+ return;
+ }
+
+ default:
+ DFG_CRASH(m_graph, m_node, "Bad use kind");
+ return;
+ }
return;
}
@@ -6039,6 +6086,260 @@
lowBlock(data->fallThrough.block), Weight(data->fallThrough.count));
}
+ void switchString(SwitchData* data, LValue string)
+ {
+ bool canDoBinarySwitch = true;
+ unsigned totalLength = 0;
+
+ for (DFG::SwitchCase myCase : data->cases) {
+ StringImpl* string = myCase.value.stringImpl();
+ if (!string->is8Bit()) {
+ canDoBinarySwitch = false;
+ break;
+ }
+ if (string->length() > Options::maximumBinaryStringSwitchCaseLength()) {
+ canDoBinarySwitch = false;
+ break;
+ }
+ totalLength += string->length();
+ }
+
+ if (!canDoBinarySwitch || totalLength > Options::maximumBinaryStringSwitchTotalLength()) {
+ switchStringSlow(data, string);
+ return;
+ }
+
+ LValue stringImpl = m_out.loadPtr(string, m_heaps.JSString_value);
+ LValue length = m_out.load32(string, m_heaps.JSString_length);
+
+ LBasicBlock hasImplBlock = FTL_NEW_BLOCK(m_out, ("Switch/SwitchString has impl case"));
+ LBasicBlock is8BitBlock = FTL_NEW_BLOCK(m_out, ("Switch/SwitchString is 8 bit case"));
+ LBasicBlock slowBlock = FTL_NEW_BLOCK(m_out, ("Switch/SwitchString slow case"));
+
+ m_out.branch(m_out.isNull(stringImpl), unsure(slowBlock), unsure(hasImplBlock));
+
+ LBasicBlock lastNext = m_out.appendTo(hasImplBlock, is8BitBlock);
+
+ m_out.branch(
+ m_out.testIsZero32(
+ m_out.load32(stringImpl, m_heaps.StringImpl_hashAndFlags),
+ m_out.constInt32(StringImpl::flagIs8Bit())),
+ unsure(slowBlock), unsure(is8BitBlock));
+
+ m_out.appendTo(is8BitBlock, slowBlock);
+
+ LValue buffer = m_out.loadPtr(stringImpl, m_heaps.StringImpl_data);
+
+ // FIXME: We should propagate branch weight data to the cases of this switch.
+ // https://bugs.webkit.org/show_bug.cgi?id=144368
+
+ Vector<StringSwitchCase> cases;
+ for (DFG::SwitchCase myCase : data->cases)
+ cases.append(StringSwitchCase(myCase.value.stringImpl(), lowBlock(myCase.target.block)));
+ std::sort(cases.begin(), cases.end());
+ switchStringRecurse(data, buffer, length, cases, 0, 0, cases.size(), 0, false);
+
+ m_out.appendTo(slowBlock, lastNext);
+ switchStringSlow(data, string);
+ }
+
+ // The code for string switching is based closely on the same code in the DFG backend. While it
+ // would be nice to reduce the amount of similar-looking code, it seems like this is one of
+ // those algorithms where factoring out the common bits would result in more code than just
+ // duplicating.
+
+ struct StringSwitchCase {
+ StringSwitchCase() { }
+
+ StringSwitchCase(StringImpl* string, LBasicBlock target)
+ : string(string)
+ , target(target)
+ {
+ }
+
+ bool operator<(const StringSwitchCase& other) const
+ {
+ return stringLessThan(*string, *other.string);
+ }
+
+ StringImpl* string;
+ LBasicBlock target;
+ };
+
+ struct CharacterCase {
+ CharacterCase()
+ : character(0)
+ , begin(0)
+ , end(0)
+ {
+ }
+
+ CharacterCase(LChar character, unsigned begin, unsigned end)
+ : character(character)
+ , begin(begin)
+ , end(end)
+ {
+ }
+
+ bool operator<(const CharacterCase& other) const
+ {
+ return character < other.character;
+ }
+
+ LChar character;
+ unsigned begin;
+ unsigned end;
+ };
+
+ void switchStringRecurse(
+ SwitchData* data, LValue buffer, LValue length, const Vector<StringSwitchCase>& cases,
+ unsigned numChecked, unsigned begin, unsigned end, unsigned alreadyCheckedLength,
+ unsigned checkedExactLength)
+ {
+ LBasicBlock fallThrough = lowBlock(data->fallThrough.block);
+
+ if (begin == end) {
+ m_out.jump(fallThrough);
+ return;
+ }
+
+ unsigned minLength = cases[begin].string->length();
+ unsigned commonChars = minLength;
+ bool allLengthsEqual = true;
+ for (unsigned i = begin + 1; i < end; ++i) {
+ unsigned myCommonChars = numChecked;
+ unsigned limit = std::min(cases[begin].string->length(), cases[i].string->length());
+ for (unsigned j = numChecked; j < limit; ++j) {
+ if (cases[begin].string->at(j) != cases[i].string->at(j))
+ break;
+ myCommonChars++;
+ }
+ commonChars = std::min(commonChars, myCommonChars);
+ if (minLength != cases[i].string->length())
+ allLengthsEqual = false;
+ minLength = std::min(minLength, cases[i].string->length());
+ }
+
+ if (checkedExactLength) {
+ DFG_ASSERT(m_graph, m_node, alreadyCheckedLength == minLength);
+ DFG_ASSERT(m_graph, m_node, allLengthsEqual);
+ }
+
+ DFG_ASSERT(m_graph, m_node, minLength >= commonChars);
+
+ if (!allLengthsEqual && alreadyCheckedLength < minLength)
+ m_out.check(m_out.below(length, m_out.constInt32(minLength)), unsure(fallThrough));
+ if (allLengthsEqual && (alreadyCheckedLength < minLength || !checkedExactLength))
+ m_out.check(m_out.notEqual(length, m_out.constInt32(minLength)), unsure(fallThrough));
+
+ for (unsigned i = numChecked; i < commonChars; ++i) {
+ m_out.check(
+ m_out.notEqual(
+ m_out.load8(buffer, m_heaps.characters8[i]),
+ m_out.constInt8(cases[begin].string->at(i))),
+ unsure(fallThrough));
+ }
+
+ if (minLength == commonChars) {
+ // This is the case where one of the cases is a prefix of all of the other cases.
+ // We've already checked that the input string is a prefix of all of the cases,
+ // so we just check length to jump to that case.
+
+ DFG_ASSERT(m_graph, m_node, cases[begin].string->length() == commonChars);
+ for (unsigned i = begin + 1; i < end; ++i)
+ DFG_ASSERT(m_graph, m_node, cases[i].string->length() > commonChars);
+
+ if (allLengthsEqual) {
+ DFG_ASSERT(m_graph, m_node, end == begin + 1);
+ m_out.jump(cases[begin].target);
+ return;
+ }
+
+ m_out.check(
+ m_out.equal(length, m_out.constInt32(commonChars)),
+ unsure(cases[begin].target));
+
+ // We've checked if the length is >= minLength, and then we checked if the length is
+ // == commonChars. We get to this point if it is >= minLength but not == commonChars.
+ // Hence we know that it now must be > minLength, i.e. that it's >= minLength + 1.
+ switchStringRecurse(
+ data, buffer, length, cases, commonChars, begin + 1, end, minLength + 1, false);
+ return;
+ }
+
+ // At this point we know that the string is longer than commonChars, and we've only verified
+ // commonChars. Use a binary switch on the next unchecked character, i.e.
+ // string[commonChars].
+
+ DFG_ASSERT(m_graph, m_node, end >= begin + 2);
+
+ LValue uncheckedChar = m_out.load8(buffer, m_heaps.characters8[commonChars]);
+
+ Vector<CharacterCase> characterCases;
+ CharacterCase currentCase(cases[begin].string->at(commonChars), begin, begin + 1);
+ for (unsigned i = begin + 1; i < end; ++i) {
+ LChar currentChar = cases[i].string->at(commonChars);
+ if (currentChar != currentCase.character) {
+ currentCase.end = i;
+ characterCases.append(currentCase);
+ currentCase = CharacterCase(currentChar, i, i + 1);
+ } else
+ currentCase.end = i + 1;
+ }
+ characterCases.append(currentCase);
+
+ Vector<LBasicBlock> characterBlocks;
+ for (CharacterCase& myCase : characterCases)
+ characterBlocks.append(FTL_NEW_BLOCK(m_out, ("Switch/SwitchString case for ", myCase.character, " at index ", commonChars)));
+
+ Vector<SwitchCase> switchCases;
+ for (unsigned i = 0; i < characterCases.size(); ++i) {
+ switchCases.append(SwitchCase(
+ m_out.constInt8(characterCases[i].character), characterBlocks[i], Weight()));
+ }
+ m_out.switchInstruction(uncheckedChar, switchCases, fallThrough, Weight());
+
+ LBasicBlock lastNext = m_out.m_nextBlock;
+ characterBlocks.append(lastNext); // Makes it convenient to set nextBlock.
+ for (unsigned i = 0; i < characterCases.size(); ++i) {
+ m_out.appendTo(characterBlocks[i], characterBlocks[i + 1]);
+ switchStringRecurse(
+ data, buffer, length, cases, commonChars + 1,
+ characterCases[i].begin, characterCases[i].end, minLength, allLengthsEqual);
+ }
+
+ DFG_ASSERT(m_graph, m_node, m_out.m_nextBlock == lastNext);
+ }
+
+ void switchStringSlow(SwitchData* data, LValue string)
+ {
+ // FIXME: We ought to be able to use computed gotos here. We would save the labels of the
+ // blocks we want to jump to, and then request their addresses after compilation completes.
+ // https://bugs.webkit.org/show_bug.cgi?id=144369
+
+ LValue branchOffset = vmCall(
+ m_out.operation(operationSwitchStringAndGetBranchOffset),
+ m_callFrame, m_out.constIntPtr(data->switchTableIndex), string);
+
+ StringJumpTable& table = codeBlock()->stringSwitchJumpTable(data->switchTableIndex);
+
+ Vector<SwitchCase> cases;
+ for (unsigned i = 0; i < data->cases.size(); ++i) {
+ DFG::SwitchCase myCase = data->cases[i];
+ StringJumpTable::StringOffsetTable::iterator iter =
+ table.offsetTable.find(myCase.value.stringImpl());
+ DFG_ASSERT(m_graph, m_node, iter != table.offsetTable.end());
+
+ cases.append(SwitchCase(
+ m_out.constInt32(iter->value.branchOffset),
+ lowBlock(myCase.target.block), Weight(myCase.target.count)));
+ }
+
+ m_out.switchInstruction(
+ branchOffset, cases, lowBlock(data->fallThrough.block),
+ Weight(data->fallThrough.count));
+ }
+
LValue doubleToInt32(LValue doubleValue, double low, double high, bool isSigned = true)
{
LBasicBlock greatEnough = FTL_NEW_BLOCK(m_out, ("doubleToInt32 greatEnough"));
@@ -7173,8 +7474,8 @@
OSRExit& exit = m_ftlState.jitCode->osrExit.last();
- LBasicBlock lastNext = 0;
- LBasicBlock continuation = 0;
+ LBasicBlock lastNext = nullptr;
+ LBasicBlock continuation = nullptr;
LBasicBlock failCase = FTL_NEW_BLOCK(m_out, ("OSR exit failCase for ", m_node));
continuation = FTL_NEW_BLOCK(m_out, ("OSR exit continuation for ", m_node));
Modified: trunk/Source/_javascript_Core/ftl/FTLOutput.cpp (183524 => 183525)
--- trunk/Source/_javascript_Core/ftl/FTLOutput.cpp 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/ftl/FTLOutput.cpp 2015-04-29 03:34:43 UTC (rev 183525)
@@ -138,6 +138,18 @@
constInt32(notTakenWeight.scaleToTotal(total))));
}
+void Output::check(LValue condition, WeightedTarget taken, Weight notTakenWeight)
+{
+ LBasicBlock continuation = FTL_NEW_BLOCK(*this, ("Output::check continuation"));
+ branch(condition, taken, WeightedTarget(continuation, notTakenWeight));
+ appendTo(continuation);
+}
+
+void Output::check(LValue condition, WeightedTarget taken)
+{
+ check(condition, taken, taken.weight().inverse());
+}
+
} } // namespace JSC::FTL
#endif // ENABLE(FTL_JIT)
Modified: trunk/Source/_javascript_Core/ftl/FTLOutput.h (183524 => 183525)
--- trunk/Source/_javascript_Core/ftl/FTLOutput.h 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/ftl/FTLOutput.h 2015-04-29 03:34:43 UTC (rev 183525)
@@ -384,7 +384,14 @@
{
branch(condition, taken.target(), taken.weight(), notTaken.target(), notTaken.weight());
}
+
+ // Branches to an already-created handler if true, "falls through" if false. Fall-through is
+ // simulated by creating a continuation for you.
+ void check(LValue condition, WeightedTarget taken, Weight notTakenWeight);
+ // Same as check(), but uses Weight::inverse() to compute the notTakenWeight.
+ void check(LValue condition, WeightedTarget taken);
+
template<typename VectorType>
void switchInstruction(LValue value, const VectorType& cases, LBasicBlock fallThrough, Weight fallThroughWeight)
{
Modified: trunk/Source/_javascript_Core/ftl/FTLWeight.h (183524 => 183525)
--- trunk/Source/_javascript_Core/ftl/FTLWeight.h 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/ftl/FTLWeight.h 2015-04-29 03:34:43 UTC (rev 183525)
@@ -62,6 +62,16 @@
return static_cast<unsigned>(result);
}
+ // Inverse weight for a two-target branch.
+ Weight inverse() const
+ {
+ if (!isSet())
+ return Weight();
+ if (value())
+ return Weight(0);
+ return Weight(1);
+ }
+
private:
float m_value;
};
Modified: trunk/Source/_javascript_Core/jit/JITOperations.h (183524 => 183525)
--- trunk/Source/_javascript_Core/jit/JITOperations.h 2015-04-29 02:26:07 UTC (rev 183524)
+++ trunk/Source/_javascript_Core/jit/JITOperations.h 2015-04-29 03:34:43 UTC (rev 183525)
@@ -157,6 +157,7 @@
typedef int32_t JIT_OPERATION (*Z_JITOperation_D)(double);
typedef int32_t JIT_OPERATION (*Z_JITOperation_E)(ExecState*);
typedef int32_t JIT_OPERATION (*Z_JITOperation_EC)(ExecState*, JSCell*);
+typedef int32_t JIT_OPERATION (*Z_JITOperation_ESJss)(ExecState*, size_t, JSString*);
typedef int32_t JIT_OPERATION (*Z_JITOperation_EJZ)(ExecState*, EncodedJSValue, int32_t);
typedef int32_t JIT_OPERATION (*Z_JITOperation_EJZZ)(ExecState*, EncodedJSValue, int32_t, int32_t);
typedef size_t JIT_OPERATION (*S_JITOperation_ECC)(ExecState*, JSCell*, JSCell*);