Commit 6f2bf6ca authored by fpizlo@apple.com's avatar fpizlo@apple.com

FTL should support all of ValueToInt32

https://bugs.webkit.org/show_bug.cgi?id=125283

Reviewed by Mark Hahnenberg.

Source/JavaScriptCore: 

* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileValueToInt32):
(JSC::FTL::LowerDFGToLLVM::compilePutByVal):
(JSC::FTL::LowerDFGToLLVM::lowCell):
(JSC::FTL::LowerDFGToLLVM::isCell):

LayoutTests: 

* js/regress/put-by-val-machine-int-expected.txt: Added.
* js/regress/put-by-val-machine-int.html: Added.
* js/regress/script-tests/put-by-val-machine-int.js: Added.
(foo):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160242 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent db19be0f
2013-12-06 Filip Pizlo <fpizlo@apple.com>
FTL should support all of ValueToInt32
https://bugs.webkit.org/show_bug.cgi?id=125283
Reviewed by Mark Hahnenberg.
* js/regress/put-by-val-machine-int-expected.txt: Added.
* js/regress/put-by-val-machine-int.html: Added.
* js/regress/script-tests/put-by-val-machine-int.js: Added.
(foo):
2013-12-06 Eric Carlson <eric.carlson@apple.com>
Unreviewed gardening, correct previous fix.
JSRegress/put-by-val-machine-int
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS no exception thrown
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script src="resources/regress-pre.js"></script>
<script src="script-tests/put-by-val-machine-int.js"></script>
<script src="resources/regress-post.js"></script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
function foo(a, v) {
a[0] = v + 2000000000;
}
noInline(foo);
for (var i = 0; i < 100000; ++i) {
var a = new Int32Array(1);
foo(a, 2000000000);
if (a[0] != -294967296)
throw "Error: bad value: " + a[0];
}
2013-12-06 Filip Pizlo <fpizlo@apple.com>
FTL should support all of ValueToInt32
https://bugs.webkit.org/show_bug.cgi?id=125283
Reviewed by Mark Hahnenberg.
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileValueToInt32):
(JSC::FTL::LowerDFGToLLVM::compilePutByVal):
(JSC::FTL::LowerDFGToLLVM::lowCell):
(JSC::FTL::LowerDFGToLLVM::isCell):
2013-12-06 Filip Pizlo <fpizlo@apple.com>
FTL shouldn't have a doubleToUInt32 path
......
......@@ -105,6 +105,7 @@ inline CapabilityLevel canCompile(Node* node)
case FunctionReentryWatchpoint:
case VariableWatchpoint:
case NotifyWrite:
case ValueToInt32:
// These are OK.
break;
case GetById:
......@@ -224,10 +225,6 @@ inline CapabilityLevel canCompile(Node* node)
return CannotCompile;
}
break;
case ValueToInt32:
if (node->child1().useKind() != BooleanUse)
return CannotCompile;
break;
default:
// Don't know how to handle anything else.
return CannotCompile;
......
......@@ -484,8 +484,96 @@ private:
void compileValueToInt32()
{
ASSERT(m_node->child1().useKind() == BooleanUse);
setInt32(m_out.zeroExt(lowBoolean(m_node->child1()), m_out.int32));
switch (m_node->child1().useKind()) {
case Int32Use:
setInt32(lowInt32(m_node->child1()));
break;
case MachineIntUse:
setInt32(m_out.castToInt32(lowStrictInt52(m_node->child1())));
break;
case NumberUse:
case NotCellUse: {
LoweredNodeValue value = m_int32Values.get(m_node->child1().node());
if (isValid(value)) {
setInt32(value.value());
break;
}
value = m_jsValueValues.get(m_node->child1().node());
if (isValid(value)) {
LBasicBlock intCase = FTL_NEW_BLOCK(m_out, ("ValueToInt32 int case"));
LBasicBlock notIntCase = FTL_NEW_BLOCK(m_out, ("ValueToInt32 not int case"));
LBasicBlock doubleCase = 0;
LBasicBlock notNumberCase = 0;
if (m_node->child1().useKind() == NotCellUse) {
doubleCase = FTL_NEW_BLOCK(m_out, ("ValueToInt32 double case"));
notNumberCase = FTL_NEW_BLOCK(m_out, ("ValueToInt32 not number case"));
}
LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("ValueToInt32 continuation"));
Vector<ValueFromBlock> results;
m_out.branch(isNotInt32(value.value()), notIntCase, intCase);
LBasicBlock lastNext = m_out.appendTo(intCase, notIntCase);
results.append(m_out.anchor(unboxInt32(value.value())));
m_out.jump(continuation);
if (m_node->child1().useKind() == NumberUse) {
m_out.appendTo(notIntCase, continuation);
FTL_TYPE_CHECK(
jsValueValue(value.value()), m_node->child1(), SpecFullNumber,
isCellOrMisc(value.value()));
results.append(m_out.anchor(doubleToInt32(unboxDouble(value.value()))));
m_out.jump(continuation);
} else {
m_out.appendTo(notIntCase, doubleCase);
m_out.branch(isCellOrMisc(value.value()), notNumberCase, doubleCase);
m_out.appendTo(doubleCase, notNumberCase);
results.append(m_out.anchor(doubleToInt32(unboxDouble(value.value()))));
m_out.jump(continuation);
m_out.appendTo(notNumberCase, continuation);
FTL_TYPE_CHECK(
jsValueValue(value.value()), m_node->child1(), ~SpecCell,
isCell(value.value()));
LValue specialResult = m_out.select(
m_out.equal(
value.value(),
m_out.constInt64(JSValue::encode(jsBoolean(true)))),
m_out.int32One, m_out.int32Zero);
results.append(m_out.anchor(specialResult));
m_out.jump(continuation);
}
m_out.appendTo(continuation, lastNext);
setInt32(m_out.phi(m_out.int32, results));
break;
}
value = m_doubleValues.get(m_node->child1().node());
if (isValid(value)) {
setInt32(doubleToInt32(value.value()));
break;
}
terminate(Uncountable);
break;
}
case BooleanUse:
setInt32(m_out.zeroExt(lowBoolean(m_node->child1()), m_out.int32));
break;
default:
RELEASE_ASSERT_NOT_REACHED();
break;
}
}
void compileInt52ToValue()
......@@ -1649,7 +1737,7 @@ private:
if (child3.useKind() == Int32Use)
intValue = lowInt32(child3);
else
intValue = m_out.castToInt32(lowInt52(child3));
intValue = m_out.castToInt32(lowStrictInt52(child3));
if (isClamped(type)) {
ASSERT(elementSize(type) == 1);
......@@ -3246,7 +3334,7 @@ private:
LValue lowCell(Edge edge, OperandSpeculationMode mode = AutomaticOperandSpeculation)
{
ASSERT_UNUSED(mode, mode == ManualOperandSpeculation || isCell(edge.useKind()));
ASSERT_UNUSED(mode, mode == ManualOperandSpeculation || DFG::isCell(edge.useKind()));
if (edge->op() == JSConstant) {
JSValue value = m_graph.valueOfJSConstant(edge.node());
......@@ -3555,6 +3643,11 @@ private:
return m_out.testNonZero64(jsValue, m_tagMask);
}
LValue isCell(LValue jsValue)
{
return m_out.testIsZero64(jsValue, m_tagMask);
}
LValue isNotBoolean(LValue jsValue)
{
return m_out.testNonZero64(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment