@@ -7559,28 +7559,26 @@ class BBQJIT {
7559
7559
7560
7560
constexpr unsigned minCasesForTable = 7 ;
7561
7561
if (minCasesForTable <= targets.size ()) {
7562
- Vector<Box<CCallHelpers::Label>> labels;
7563
- labels.reserveInitialCapacity (targets.size ());
7564
7562
auto * jumpTable = m_callee.addJumpTable (targets.size ());
7565
7563
auto fallThrough = m_jit.branch32 (RelationalCondition::AboveOrEqual, wasmScratchGPR, TrustedImm32 (targets.size ()));
7566
7564
m_jit.zeroExtend32ToWord (wasmScratchGPR, wasmScratchGPR);
7567
7565
m_jit.lshiftPtr (TrustedImm32 (3 ), wasmScratchGPR);
7568
7566
m_jit.addPtr (TrustedImmPtr (jumpTable->data ()), wasmScratchGPR);
7569
7567
m_jit.farJump (Address (wasmScratchGPR), JSSwitchPtrTag);
7570
7568
7571
- for (unsigned index = 0 ; index < targets.size (); ++index) {
7572
- Box<CCallHelpers::Label> label = Box<CCallHelpers::Label>::create (m_jit.label ());
7573
- labels.unsafeAppendWithoutCapacityCheck (label);
7574
- bool isCodeEmitted = currentControlData ().addExit (*this , targets[index]->targetLocations (), results);
7569
+ auto labels = WTF::map (targets, [&](auto & target) {
7570
+ auto label = Box<CCallHelpers::Label>::create (m_jit.label ());
7571
+ bool isCodeEmitted = currentControlData ().addExit (*this , target->targetLocations (), results);
7575
7572
if (isCodeEmitted)
7576
- targets[index] ->addBranch (m_jit.jump ());
7573
+ target ->addBranch (m_jit.jump ());
7577
7574
else {
7578
7575
// It is common that we do not need to emit anything before jumping to the target block.
7579
7576
// In that case, we put Box<Label> which will be filled later when the end of the block is linked.
7580
7577
// We put direct jump to that block in the link task.
7581
- targets[index] ->addLabel (WTFMove ( label) );
7578
+ target ->addLabel (Box { label } );
7582
7579
}
7583
- }
7580
+ return label;
7581
+ });
7584
7582
7585
7583
m_jit.addLinkTask ([labels = WTFMove (labels), jumpTable](LinkBuffer& linkBuffer) {
7586
7584
for (unsigned index = 0 ; index < labels.size (); ++index)
0 commit comments