Diff
Modified: trunk/JSTests/ChangeLog (253894 => 253895)
--- trunk/JSTests/ChangeLog 2019-12-24 01:03:13 UTC (rev 253894)
+++ trunk/JSTests/ChangeLog 2019-12-24 01:11:13 UTC (rev 253895)
@@ -1,3 +1,12 @@
+2019-12-23 Yusuke Suzuki <[email protected]>
+
+ [JSC] Wasm OSR entry should capture top-most enclosing-stack
+ https://bugs.webkit.org/show_bug.cgi?id=205571
+
+ Reviewed by Keith Miller.
+
+ * wasm/stress/top-most-enclosing-stack.js: Added.
+
2019-12-21 Yusuke Suzuki <[email protected]>
[JSC] Improve our bound function implementation
Added: trunk/JSTests/wasm/stress/top-most-enclosing-stack.js (0 => 253895)
--- trunk/JSTests/wasm/stress/top-most-enclosing-stack.js (rev 0)
+++ trunk/JSTests/wasm/stress/top-most-enclosing-stack.js 2019-12-24 01:11:13 UTC (rev 253895)
@@ -0,0 +1,27 @@
+import { instantiate } from "../wabt-wrapper.js";
+
+let wat = `
+(module
+ (func (export "test") (param i32) (result i32) (local $l0 i32)
+ local.get 0
+ i32.const 42
+ i32.add
+ (loop $L0 (result i32)
+ local.get $l0
+ i32.const 1
+ i32.add
+ local.set $l0
+ local.get $l0
+ i32.const 100000
+ i32.lt_u
+ br_if 0
+ i32.const 44
+ )
+ i32.add
+ )
+)
+`;
+
+let instance = instantiate(wat);
+if (instance.exports.test(44) !== 130)
+ throw new Error();
Modified: trunk/Source/_javascript_Core/ChangeLog (253894 => 253895)
--- trunk/Source/_javascript_Core/ChangeLog 2019-12-24 01:03:13 UTC (rev 253894)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-12-24 01:11:13 UTC (rev 253895)
@@ -1,3 +1,23 @@
+2019-12-23 Yusuke Suzuki <[email protected]>
+
+ [JSC] Wasm OSR entry should capture top-most enclosing-stack
+ https://bugs.webkit.org/show_bug.cgi?id=205571
+
+ Reviewed by Keith Miller.
+
+ OSR entry should capture the top-most enclosing-stack too.
+ Otherwise the def-node can be unreachable (since it is defined in BB which is unreachable from OSR entry point),
+ and eliminated.
+
+ * wasm/WasmAirIRGenerator.cpp:
+ (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck):
+ (JSC::Wasm::AirIRGenerator::addLoop):
+ * wasm/WasmB3IRGenerator.cpp:
+ (JSC::Wasm::B3IRGenerator::emitLoopTierUpCheck):
+ (JSC::Wasm::B3IRGenerator::addLoop):
+ * wasm/WasmLLIntGenerator.cpp:
+ (JSC::Wasm::LLIntGenerator::addLoop):
+
2019-12-23 Carlos Garcia Campos <[email protected]>
WebDriver: fix handling of session timeouts for values higher than MAX_INT
Modified: trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp (253894 => 253895)
--- trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp 2019-12-24 01:03:13 UTC (rev 253894)
+++ trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp 2019-12-24 01:11:13 UTC (rev 253895)
@@ -637,7 +637,7 @@
void emitThrowException(CCallHelpers&, ExceptionType);
void emitEntryTierUpCheck();
- void emitLoopTierUpCheck(uint32_t loopIndex);
+ void emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack);
void emitWriteBarrierForJSWrapper();
ExpressionType emitCheckAndPreparePointer(ExpressionType pointer, uint32_t offset, uint32_t sizeOfOp);
@@ -1765,7 +1765,7 @@
emitPatchpoint(patch, Tmp(), countdownPtr);
}
-void AirIRGenerator::emitLoopTierUpCheck(uint32_t loopIndex)
+void AirIRGenerator::emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack)
{
uint32_t outerLoopIndex = this->outerLoopIndex();
m_outerLoops.append(loopIndex);
@@ -1803,6 +1803,8 @@
for (TypedExpression value : expressionStack)
patchArgs.append(ConstrainedTmp(value.value(), B3::ValueRep::ColdAny));
}
+ for (TypedExpression value : enclosingStack)
+ patchArgs.append(ConstrainedTmp(value.value(), B3::ValueRep::ColdAny));
TierUpCount::TriggerReason* forceEntryTrigger = &(m_tierUp->osrEntryTriggers().last());
static_assert(!static_cast<uint8_t>(TierUpCount::TriggerReason::DontTrigger), "the JIT code assumes non-zero means 'enter'");
@@ -1854,7 +1856,7 @@
m_currentBlock->setSuccessors(body);
m_currentBlock = body;
- emitLoopTierUpCheck(loopIndex);
+ emitLoopTierUpCheck(loopIndex, enclosingStack);
return { };
}
Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (253894 => 253895)
--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2019-12-24 01:03:13 UTC (rev 253894)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2019-12-24 01:11:13 UTC (rev 253895)
@@ -282,7 +282,7 @@
void emitExceptionCheck(CCallHelpers&, ExceptionType);
void emitEntryTierUpCheck();
- void emitLoopTierUpCheck(uint32_t loopIndex);
+ void emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack);
void emitWriteBarrierForJSWrapper();
ExpressionType emitCheckAndPreparePointer(ExpressionType pointer, uint32_t offset, uint32_t sizeOfOp);
@@ -1274,7 +1274,7 @@
});
}
-void B3IRGenerator::emitLoopTierUpCheck(uint32_t loopIndex)
+void B3IRGenerator::emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack)
{
uint32_t outerLoopIndex = this->outerLoopIndex();
m_outerLoops.append(loopIndex);
@@ -1299,6 +1299,8 @@
for (TypedExpression value : expressionStack)
stackmap.append(value);
}
+ for (TypedExpression value : enclosingStack)
+ stackmap.append(value);
PatchpointValue* patch = m_currentBlock->appendNew<PatchpointValue>(m_proc, B3::Void, origin);
Effects effects = Effects::none();
@@ -1381,10 +1383,7 @@
for (auto& local : m_locals)
m_currentBlock->appendNew<VariableValue>(m_proc, Set, Origin(), local, loadFromScratchBuffer(local->type()));
- for (unsigned controlIndex = 0; controlIndex < m_parser->controlStack().size(); ++controlIndex) {
- const auto& data = ""
- auto& expressionStack = m_parser->controlStack()[controlIndex].enclosedExpressionStack;
-
+ auto connectControlEntry = [&](const ControlData& data, Stack& expressionStack) {
// For each stack entry enclosed by this loop we need to replace the value with a phi so we can fill it on OSR entry.
BasicBlock* sourceBlock = nullptr;
unsigned blockIndex = 0;
@@ -1397,7 +1396,8 @@
}
if (value->owner != sourceBlock) {
- insertionSet.execute(sourceBlock);
+ if (sourceBlock)
+ insertionSet.execute(sourceBlock);
ASSERT(insertionSet.isEmpty());
dataLogLnIf(WasmB3IRGeneratorInternal::verbose && sourceBlock, "Executed insertion set into: ", *sourceBlock);
blockIndex = 0;
@@ -1415,8 +1415,16 @@
auto* sourceUpsilon = m_proc.add<UpsilonValue>(value->origin(), value, phi);
insertionSet.insertValue(blockIndex, sourceUpsilon);
}
- insertionSet.execute(sourceBlock);
+ if (sourceBlock)
+ insertionSet.execute(sourceBlock);
+ };
+
+ for (unsigned controlIndex = 0; controlIndex < m_parser->controlStack().size(); ++controlIndex) {
+ auto& data = ""
+ auto& expressionStack = m_parser->controlStack()[controlIndex].enclosedExpressionStack;
+ connectControlEntry(data, expressionStack);
}
+ connectControlEntry(block, enclosingStack);
m_osrEntryScratchBufferSize = indexInBuffer;
m_currentBlock->appendNewControlValue(m_proc, Jump, origin(), body);
@@ -1424,7 +1432,7 @@
}
m_currentBlock = body;
- emitLoopTierUpCheck(loopIndex);
+ emitLoopTierUpCheck(loopIndex, enclosingStack);
return { };
}
Modified: trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp (253894 => 253895)
--- trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp 2019-12-24 01:03:13 UTC (rev 253894)
+++ trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp 2019-12-24 01:11:13 UTC (rev 253895)
@@ -833,6 +833,8 @@
for (TypedExpression _expression_ : expressionStack)
osrEntryData.append(_expression_);
}
+ for (TypedExpression _expression_ : enclosingStack)
+ osrEntryData.append(_expression_);
WasmLoopHint::emit(this);