diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h')
-rw-r--r-- | Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h b/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h index 349912175..e12cd8edc 100644 --- a/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h +++ b/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,45 +23,64 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BytecodeLivenessAnalysis_h -#define BytecodeLivenessAnalysis_h +#pragma once #include "BytecodeBasicBlock.h" +#include "BytecodeGraph.h" +#include "CodeBlock.h" #include <wtf/FastBitVector.h> #include <wtf/HashMap.h> #include <wtf/Vector.h> namespace JSC { -class CodeBlock; +class BytecodeKills; class FullBytecodeLiveness; -class BytecodeLivenessAnalysis { +template<typename DerivedAnalysis> +class BytecodeLivenessPropagation { +protected: + template<typename Graph, typename UseFunctor, typename DefFunctor> void stepOverInstruction(Graph&, unsigned bytecodeOffset, FastBitVector& out, const UseFunctor&, const DefFunctor&); + + template<typename Graph> void stepOverInstruction(Graph&, unsigned bytecodeOffset, FastBitVector& out); + + template<typename Graph> bool computeLocalLivenessForBytecodeOffset(Graph&, BytecodeBasicBlock*, unsigned targetOffset, FastBitVector& result); + + template<typename Graph> bool computeLocalLivenessForBlock(Graph&, BytecodeBasicBlock*); + + template<typename Graph> FastBitVector getLivenessInfoAtBytecodeOffset(Graph&, unsigned bytecodeOffset); + + template<typename Graph> void runLivenessFixpoint(Graph&); +}; + +class BytecodeLivenessAnalysis : private BytecodeLivenessPropagation<BytecodeLivenessAnalysis> { + WTF_MAKE_FAST_ALLOCATED; + WTF_MAKE_NONCOPYABLE(BytecodeLivenessAnalysis); public: + friend class BytecodeLivenessPropagation<BytecodeLivenessAnalysis>; BytecodeLivenessAnalysis(CodeBlock*); bool operandIsLiveAtBytecodeOffset(int operand, unsigned bytecodeOffset); FastBitVector getLivenessInfoAtBytecodeOffset(unsigned bytecodeOffset); void computeFullLiveness(FullBytecodeLiveness& result); + void computeKills(BytecodeKills& result); private: void compute(); - void runLivenessFixpoint(); void dumpResults(); - void getLivenessInfoForNonCapturedVarsAtBytecodeOffset(unsigned bytecodeOffset, FastBitVector&); + void getLivenessInfoAtBytecodeOffset(unsigned bytecodeOffset, FastBitVector&); - CodeBlock* m_codeBlock; - Vector<RefPtr<BytecodeBasicBlock> > m_basicBlocks; -}; + template<typename Functor> void computeDefsForBytecodeOffset(CodeBlock*, OpcodeID, Instruction*, FastBitVector&, const Functor&); + template<typename Functor> void computeUsesForBytecodeOffset(CodeBlock*, OpcodeID, Instruction*, FastBitVector&, const Functor&); -inline bool operandIsAlwaysLive(CodeBlock*, int operand); -inline bool operandThatIsNotAlwaysLiveIsLive(CodeBlock*, const FastBitVector& out, int operand); -inline bool operandIsLive(CodeBlock*, const FastBitVector& out, int operand); + BytecodeGraph<CodeBlock> m_graph; +}; -FastBitVector getLivenessInfo(CodeBlock*, const FastBitVector& out); +inline bool operandIsAlwaysLive(int operand); +inline bool operandThatIsNotAlwaysLiveIsLive(const FastBitVector& out, int operand); +inline bool operandIsLive(const FastBitVector& out, int operand); +inline bool isValidRegisterForLiveness(int operand); } // namespace JSC - -#endif // BytecodeLivenessAnalysis_h |