Changeset 280507 in webkit
- Timestamp:
- Jul 30, 2021, 6:40:05 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/wasm/stress/osr-entry-with-loop-arguments.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/b3/B3Validate.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp (modified) (6 diffs)
-
Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r280505 r280507 1 2021-07-30 Robin Morisset <rmorisset@apple.com> 2 3 Improve OSR entry into Wasm loops with arguments 4 https://bugs.webkit.org/show_bug.cgi?id=228595 5 6 Reviewed by Yusuke Suzuki. 7 8 Just a straightforward test that counts to 1M in a loop, to exercise both OSR entry and a loop with an argument at the same time. 9 100k iterations was not enough to reliably complete an OSR entry. 10 11 * wasm/stress/osr-entry-with-loop-arguments.js: Added. 12 (async test): 13 1 14 2021-07-30 Tadeu Zagallo <tzagallo@apple.com> 2 15 -
trunk/Source/JavaScriptCore/ChangeLog
r280506 r280507 1 2021-07-30 Robin Morisset <rmorisset@apple.com> 2 3 Improve OSR entry into Wasm loops with arguments 4 https://bugs.webkit.org/show_bug.cgi?id=228595 5 6 Reviewed by Yusuke Suzuki. 7 8 This patch has two parts: 9 - improve the Wasm OSR code to fully support loop arguments (just some plumbing to make sure that the right values are propagated) 10 - improve the B3 validator to fix a hole I noticed while writing the first part: we were not detecting code that introduce Upsilons in the wrong blocks. 11 Naturally, this caused hard to debug issues, as B3 has no well-defined semantics for a Phi that is reached before the corresponding Upsilon(s). 12 13 * b3/B3Validate.cpp: 14 * wasm/WasmAirIRGenerator.cpp: 15 (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): 16 (JSC::Wasm::AirIRGenerator::addLoop): 17 * wasm/WasmB3IRGenerator.cpp: 18 (JSC::Wasm::B3IRGenerator::emitLoopTierUpCheck): 19 (JSC::Wasm::B3IRGenerator::addLoop): 20 * wasm/WasmLLIntGenerator.cpp: 21 (JSC::Wasm::LLIntGenerator::addLoop): 22 1 23 2021-07-30 Philip Chimento <pchimento@igalia.com> 2 24 -
trunk/Source/JavaScriptCore/b3/B3Validate.cpp
r278253 r280507 573 573 VALIDATE(block->numPredecessors() == predecessors.size(), ("At ", *block)); 574 574 } 575 576 validatePhisAreDominatedByUpsilons(); 575 577 } 576 578 … … 653 655 VALIDATE(memory->offset() >= 0, ("At ", *value)); 654 656 } 655 657 658 // A simple backwards analysis to check that we cannot reach a Phi without going through a corresponding Upsilon 659 // We cannot use the dominator tree, since we are checking that each Phi is dominated by a the set of all of its upsilons, and not by a single node. 660 void validatePhisAreDominatedByUpsilons() 661 { 662 bool changed = true; 663 BitVector blocksToVisit; 664 IndexMap<BasicBlock*, HashSet<Value*>> undominatedPhisAtTail(m_procedure.size()); 665 for (BasicBlock* block : m_procedure) 666 blocksToVisit.set(block->index()); 667 while (changed) { 668 changed = false; 669 for (BasicBlock* block : m_procedure.blocksInPostOrder()) { 670 if (!blocksToVisit.quickClear(block->index())) 671 continue; 672 HashSet<Value*> undominatedPhis = undominatedPhisAtTail[block]; 673 for (unsigned index = block->size()-1; index--;) { 674 Value* value = block->at(index); 675 switch (value->opcode()) { 676 case Upsilon: 677 undominatedPhis.remove(value->as<UpsilonValue>()->phi()); 678 break; 679 case Phi: 680 VALIDATE(!undominatedPhis.contains(value), ("At ", *value)); 681 undominatedPhis.add(value); 682 break; 683 default: 684 break; 685 } 686 } 687 for (BasicBlock* predecessor : block->predecessors()) { 688 bool changedSet = false; 689 for (Value* phi : undominatedPhis) 690 changedSet |= undominatedPhisAtTail[predecessor].add(phi).isNewEntry; 691 if (changedSet) { 692 blocksToVisit.quickSet(predecessor->index()); 693 changed = true; 694 } 695 } 696 if (!block->index()) 697 VALIDATE(undominatedPhis.isEmpty(), ("Undominated phi at top of entry block: ", **undominatedPhis.begin())); 698 } 699 } 700 } 701 656 702 NO_RETURN_DUE_TO_CRASH void fail( 657 703 const char* filename, int lineNumber, const char* function, const char* condition, -
trunk/Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp
r279341 r280507 669 669 670 670 void emitEntryTierUpCheck(); 671 void emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack );671 void emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack, const Stack& newStack); 672 672 673 673 void emitWriteBarrierForJSWrapper(); … … 2847 2847 } 2848 2848 2849 void AirIRGenerator::emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack )2849 void AirIRGenerator::emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack, const Stack& newStack) 2850 2850 { 2851 2851 uint32_t outerLoopIndex = this->outerLoopIndex(); … … 2885 2885 } 2886 2886 for (TypedExpression value : enclosingStack) 2887 patchArgs.append(ConstrainedTmp(value.value(), B3::ValueRep::ColdAny)); 2888 for (TypedExpression value : newStack) 2887 2889 patchArgs.append(ConstrainedTmp(value.value(), B3::ValueRep::ColdAny)); 2888 2890 … … 2937 2939 2938 2940 m_currentBlock = body; 2939 emitLoopTierUpCheck(loopIndex, enclosingStack );2941 emitLoopTierUpCheck(loopIndex, enclosingStack, newStack); 2940 2942 2941 2943 return { }; -
trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
r279341 r280507 305 305 306 306 void emitEntryTierUpCheck(); 307 void emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack );307 void emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack, const Stack& newStack); 308 308 309 309 void emitWriteBarrierForJSWrapper(); … … 2068 2068 } 2069 2069 2070 void B3IRGenerator::emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack )2070 void B3IRGenerator::emitLoopTierUpCheck(uint32_t loopIndex, const Stack& enclosingStack, const Stack& newStack) 2071 2071 { 2072 2072 uint32_t outerLoopIndex = this->outerLoopIndex(); … … 2094 2094 } 2095 2095 for (TypedExpression value : enclosingStack) 2096 stackmap.append(value); 2097 for (TypedExpression value : newStack) 2096 2098 stackmap.append(value); 2097 2099 … … 2145 2147 2146 2148 block = ControlData(m_proc, origin(), signature, BlockType::Loop, continuation, body); 2147 2148 ExpressionList args; 2149 { 2150 unsigned offset = enclosingStack.size() - signature->argumentCount(); 2151 for (unsigned i = 0; i < signature->argumentCount(); ++i) { 2152 TypedExpression value = enclosingStack.at(offset + i); 2153 auto* upsilon = m_currentBlock->appendNew<UpsilonValue>(m_proc, origin(), value); 2154 Value* phi = block.phis[i]; 2155 body->append(phi); 2156 upsilon->setPhi(phi); 2157 newStack.constructAndAppend(value.type(), phi); 2158 } 2159 enclosingStack.shrink(offset); 2149 unsigned offset = enclosingStack.size() - signature->argumentCount(); 2150 for (unsigned i = 0; i < signature->argumentCount(); ++i) { 2151 TypedExpression value = enclosingStack.at(offset + i); 2152 auto* upsilon = m_currentBlock->appendNew<UpsilonValue>(m_proc, origin(), value); 2153 Value* phi = block.phis[i]; 2154 body->append(phi); 2155 upsilon->setPhi(phi); 2156 newStack.constructAndAppend(value.type(), phi); 2160 2157 } 2161 2158 … … 2218 2215 connectControlEntry(data, expressionStack); 2219 2216 } 2217 for (unsigned i = 0; i < signature->argumentCount(); ++i) { 2218 TypedExpression value = enclosingStack.at(offset + i); 2219 Value* phi = block.phis[i]; 2220 m_currentBlock->appendNew<UpsilonValue>(m_proc, value->origin(), loadFromScratchBuffer(value->type()), phi); 2221 } 2222 enclosingStack.shrink(offset); 2220 2223 connectControlEntry(block, enclosingStack); 2221 2224 … … 2223 2226 m_currentBlock->appendNewControlValue(m_proc, Jump, origin(), body); 2224 2227 body->addPredecessor(m_currentBlock); 2225 } 2228 } else 2229 enclosingStack.shrink(offset); 2226 2230 2227 2231 m_currentBlock = body; 2228 emitLoopTierUpCheck(loopIndex, enclosingStack );2232 emitLoopTierUpCheck(loopIndex, enclosingStack, newStack); 2229 2233 return { }; 2230 2234 } -
trunk/Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp
r279265 r280507 923 923 for (TypedExpression expression : enclosingStack) 924 924 osrEntryData.append(expression); 925 for (TypedExpression expression : newStack) 926 osrEntryData.append(expression); 925 927 926 928 WasmLoopHint::emit(this);
Note:
See TracChangeset
for help on using the changeset viewer.