blob: d6e8ace3a918c0d0c49371d30e875cb66170b963 [file] [log] [blame]
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#pragma once
#if ENABLE(DFG_JIT)
#include "DFGDominators.h"
#include "DFGGraph.h"
namespace JSC { namespace DFG {
class EdgeDominates {
static const bool verbose = false;
public:
EdgeDominates(Graph& graph, BasicBlock* block)
: m_graph(graph)
, m_block(block)
, m_result(true)
{
}
void operator()(Node*, Edge edge)
{
bool result = m_graph.m_dominators->dominates(edge.node()->owner, m_block);
if (verbose) {
dataLog(
"Checking if ", edge, " in ", *edge.node()->owner,
" dominates ", *m_block, ": ", result, "\n");
}
m_result &= result;
}
bool result() const { return m_result; }
private:
Graph& m_graph;
BasicBlock* m_block;
bool m_result;
};
inline bool edgesDominate(Graph& graph, Node* node, BasicBlock* block)
{
EdgeDominates edgeDominates(graph, block);
DFG_NODE_DO_TO_CHILDREN(graph, node, edgeDominates);
return edgeDominates.result();
}
} } // namespace JSC::DFG
#endif // ENABLE(DFG_JIT)