Ignore:
Timestamp:
Jul 7, 2020, 5:32:35 PM (5 years ago)
Author:
[email protected]
Message:

Bytecode UseDef should be aware of checkpoints
https://bugs.webkit.org/show_bug.cgi?id=213566

Reviewed by Saam Barati.

JSTests:

  • stress/def-then-use-in-single-bytecode-with-checkpoints-for-of.js: Added.

(foo):

Source/JavaScriptCore:

Previously, we tried to solve teaching DFG about uses and defs of
locals across checkpoints by asking what locals were def'd at some
checkpoint. However, this was subtly wrong because we couldn't
report any uses at subsequent checkpoints so DFG thought the
local was dead immediately after its birth.

This patch reverts that change and instead teaches BytecodeUseDef
about checkpoints. Right now, BytecodeUseDef only knows about
locals at checkpoints but in the future we may teach it about tmps
at well.

Since the vectors containing our liveness bitmaps were already
sparse (they are indexed by the bytecode offset) we can reuse the
gaps to hold our checkpoint liveness information. To make sure we
don't overlap between the next bytecode and a checkpoint for the
current bytecode there is now a static assert that the length of
the bytecode is greater than the number of checkpoints. This
assumption is already true for existing bytecodes with checkpoints (and
likely to be true for future ones anyway).

Many of the BytecodeLivenessPropegation functions have been
renamed to reflect that they operate over the full instruction,
including checkpoints, rather than just the BytecodeIndex passed.

Lastly, this patch makes a speculative fix to forAllKilledOperands where we
wouldn't report that all tmps die at the end of each bytecode. I can't think
of a case where this would break things but it's probably good hygiene.

  • bytecode/BytecodeGeneratorification.cpp:

(JSC::GeneratorLivenessAnalysis::run):

  • bytecode/BytecodeIndex.h:

(JSC::BytecodeIndex::BytecodeIndex):
(JSC::BytecodeIndex::checkpoint const):
(JSC::BytecodeIndex::withCheckpoint const):
(JSC::BytecodeIndex::pack):

  • bytecode/BytecodeLivenessAnalysis.cpp:

(JSC::BytecodeLivenessAnalysis::computeFullLiveness):
(JSC::BytecodeLivenessAnalysis::dumpResults):
(JSC::tmpLivenessForCheckpoint):
(JSC::BytecodeLivenessAnalysis::getLivenessInfoAtBytecodeIndex): Deleted.
(JSC::livenessForCheckpoint): Deleted.

  • bytecode/BytecodeLivenessAnalysis.h:

(JSC::BytecodeLivenessAnalysis::getLivenessInfoAtInstruction):

  • bytecode/BytecodeLivenessAnalysisInlines.h:

(JSC::BytecodeLivenessPropagation::stepOverBytecodeIndexDef):
(JSC::BytecodeLivenessPropagation::stepOverBytecodeIndexUse):
(JSC::BytecodeLivenessPropagation::stepOverBytecodeIndexUseInExceptionHandler):
(JSC::BytecodeLivenessPropagation::stepOverBytecodeIndex):
(JSC::BytecodeLivenessPropagation::stepOverInstruction):
(JSC::BytecodeLivenessPropagation::computeLocalLivenessForInstruction):
(JSC::BytecodeLivenessPropagation::computeLocalLivenessForBlock):
(JSC::BytecodeLivenessPropagation::getLivenessInfoAtInstruction):
(JSC::BytecodeLivenessPropagation::stepOverInstructionDef): Deleted.
(JSC::BytecodeLivenessPropagation::stepOverInstructionUse): Deleted.
(JSC::BytecodeLivenessPropagation::stepOverInstructionUseInExceptionHandler): Deleted.
(JSC::BytecodeLivenessPropagation::computeLocalLivenessForBytecodeIndex): Deleted.
(JSC::BytecodeLivenessPropagation::getLivenessInfoAtBytecodeIndex): Deleted.

  • bytecode/BytecodeUseDef.cpp:

(JSC::computeUsesForBytecodeIndexImpl):
(JSC::computeDefsForBytecodeIndexImpl):

  • bytecode/BytecodeUseDef.h:

(JSC::computeUsesForBytecodeIndex):
(JSC::computeDefsForBytecodeIndex):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndexSlow):
(JSC::CodeBlock::validate):

  • bytecode/FullBytecodeLiveness.h:

(JSC::FullBytecodeLiveness::getLiveness const):
(JSC::FullBytecodeLiveness::toIndex):

  • bytecode/Instruction.h:

(JSC::BaseInstruction::numberOfCheckpoints const):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::ForInContext::finalize):

  • dfg/DFGForAllKills.h:

(JSC::DFG::forAllKilledOperands):

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::isLiveInBytecode):

  • dfg/DFGGraph.h:
  • dfg/DFGMovHintRemovalPhase.cpp:
  • dfg/DFGPlan.cpp:

(JSC::DFG::Plan::cleanMustHandleValuesIfNecessary):

  • generator/Opcode.rb:
  • generator/Section.rb:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r263035 r264049  
    52165216        auto instruction = generator.instructions().at(offset);
    52175217        ASSERT(!instruction->is<OpEnter>());
    5218         computeDefsForBytecodeIndex(codeBlock, instruction.ptr(), [&] (VirtualRegister operand) {
    5219             if (local()->virtualRegister() == operand)
    5220                 invalidate();
    5221         });
     5218        for (Checkpoint checkpoint = instruction->numberOfCheckpoints(); checkpoint--;) {
     5219            computeDefsForBytecodeIndex(codeBlock, instruction.ptr(), checkpoint, [&] (VirtualRegister operand) {
     5220                if (local()->virtualRegister() == operand)
     5221                    invalidate();
     5222            });
     5223        }
    52225224        offset += instruction->size();
    52235225    }
Note: See TracChangeset for help on using the changeset viewer.