Ignore:
Timestamp:
Mar 14, 2017, 2:37:41 PM (8 years ago)
Author:
[email protected]
Message:

Record the HashSet/HashMap operations in DFG/FTL/B3 and replay them in a benchmark
https://bugs.webkit.org/show_bug.cgi?id=169590

Reviewed by Saam Barati.

Source/JavaScriptCore:

Adds code to support logging some hashtable stuff in the DFG.

  • dfg/DFGAvailabilityMap.cpp:

(JSC::DFG::AvailabilityMap::pruneHeap):

  • dfg/DFGCombinedLiveness.cpp:

(JSC::DFG::liveNodesAtHead):
(JSC::DFG::CombinedLiveness::CombinedLiveness):

  • dfg/DFGCombinedLiveness.h:
  • dfg/DFGLivenessAnalysisPhase.cpp:

(JSC::DFG::LivenessAnalysisPhase::run):
(JSC::DFG::LivenessAnalysisPhase::processBlock):

  • dfg/DFGNode.cpp:
  • dfg/DFGNode.h:
  • dfg/DFGObjectAllocationSinkingPhase.cpp:

Source/WTF:

This adds LoggingHashSet and LoggingHashMap, which are drop-in replacements for HashSet and
HashMap that log everything that they do, so that you can replay it later.

This also adds a benchmark (HashSetDFGReplay) based on doing a recording of some of the HashSets
in the DFG compiler.

  • WTF.xcodeproj/project.pbxproj:
  • benchmarks/HashSetDFGReplay.cpp: Added.

(benchmark):
(main):

  • wtf/CMakeLists.txt:
  • wtf/GlobalVersion.cpp: Added.

(WTF::newGlobalVersion):

  • wtf/GlobalVersion.h: Added.
  • wtf/HashMap.h:

(WTF::X>::swap):

  • wtf/HashSet.h:

(WTF::V>::addVoid):

  • wtf/LoggingHashID.h: Added.

(WTF::LoggingHashID::LoggingHashID):
(WTF::LoggingHashID::dump):

  • wtf/LoggingHashMap.h: Added.
  • wtf/LoggingHashSet.h: Added.
  • wtf/LoggingHashTraits.h: Added.

(WTF::LoggingHashKeyTraits::print):
(WTF::LoggingHashValueTraits::print):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGLivenessAnalysisPhase.cpp

    r208373 r213939  
    11/*
    2  * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3838#include <wtf/BitVector.h>
    3939#include <wtf/IndexSparseSet.h>
     40#include <wtf/LoggingHashSet.h>
    4041
    4142namespace JSC { namespace DFG {
     43
     44// Uncomment this to log hashtable operations.
     45// static const char templateString[] = "unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>";
     46// typedef LoggingHashSet<templateString, unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> LiveSet;
     47
     48typedef HashSet<unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> LiveSet;
    4249
    4350class LivenessAnalysisPhase : public Phase {
     
    9299            }
    93100            {
    94                 const HashSet<unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>& liveAtTailIndices = m_liveAtTail[blockIndex];
     101                const LiveSet& liveAtTailIndices = m_liveAtTail[blockIndex];
    95102                Vector<NodeFlowProjection>& liveAtTail = block->ssa->liveAtTail;
    96103                liveAtTail.resize(0);
     
    158165        bool changedPredecessor = false;
    159166        for (BasicBlock* predecessor : block->predecessors) {
    160             HashSet<unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>&
    161                 liveAtTail = m_liveAtTail[predecessor];
     167            LiveSet& liveAtTail = m_liveAtTail[predecessor];
    162168            for (unsigned newValue : *m_workset) {
    163169                if (liveAtTail.add(newValue)) {
     
    177183    // Live values per block edge.
    178184    BlockMap<Vector<unsigned, 0, UnsafeVectorOverflow, 1>> m_liveAtHead;
    179     BlockMap<HashSet<unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>> m_liveAtTail;
     185    BlockMap<LiveSet> m_liveAtTail;
    180186
    181187    // Single sparse set allocated once and used by every basic block.
Note: See TracChangeset for help on using the changeset viewer.