Chromium Code Reviews| Index: src/compiler/bytecode-analysis.h | 
| diff --git a/src/compiler/bytecode-analysis.h b/src/compiler/bytecode-analysis.h | 
| index 1e443575b59090b5d2eba40e1ba73c16e35b856b..9993b9d744ffcd1af4b1e32945332292c5ffcd05 100644 | 
| --- a/src/compiler/bytecode-analysis.h | 
| +++ b/src/compiler/bytecode-analysis.h | 
| @@ -9,6 +9,7 @@ | 
| #include "src/bit-vector.h" | 
| #include "src/compiler/bytecode-liveness-map.h" | 
| #include "src/handles.h" | 
| +#include "src/interpreter/bytecode-register.h" | 
| #include "src/zone/zone-containers.h" | 
| namespace v8 { | 
| @@ -18,23 +19,66 @@ class BytecodeArray; | 
| namespace compiler { | 
| +class V8_EXPORT_PRIVATE BytecodeLoopAssignments { | 
| + public: | 
| + BytecodeLoopAssignments(int parameter_count, int register_count, Zone* zone); | 
| + | 
| + void Add(interpreter::Register r); | 
| + void AddPair(interpreter::Register r); | 
| + void AddTriple(interpreter::Register r); | 
| + void AddAll(); | 
| + void Union(const BytecodeLoopAssignments& other); | 
| + | 
| + bool ContainsParameter(int index) const; | 
| + bool ContainsLocal(int index) const; | 
| + bool ContainsAccumulator() const; | 
| + | 
| + int parameter_count() const { return parameter_count_; } | 
| + int local_count() const { return bit_vector_->length() - parameter_count_; } | 
| + | 
| + private: | 
| + int parameter_count_; | 
| + BitVector* bit_vector_; | 
| +}; | 
| + | 
| +struct V8_EXPORT_PRIVATE LoopInfo { | 
| + public: | 
| + LoopInfo(int parent_offset, int parameter_count, int register_count, | 
| + Zone* zone) | 
| + : parent_offset_(parent_offset), | 
| + assignments_(parameter_count, register_count, zone) {} | 
| + | 
| + int parent_offset() const { return parent_offset_; } | 
| + | 
| + BytecodeLoopAssignments& assignments() { return assignments_; } | 
| + const BytecodeLoopAssignments& assignments() const { return assignments_; } | 
| + | 
| + private: | 
| + // The offset to the parent loop, or -1 if there is no parent. | 
| + int parent_offset_; | 
| + BytecodeLoopAssignments assignments_; | 
| +}; | 
| + | 
| class V8_EXPORT_PRIVATE BytecodeAnalysis BASE_EMBEDDED { | 
| public: | 
| BytecodeAnalysis(Handle<BytecodeArray> bytecode_array, Zone* zone, | 
| bool do_liveness_analysis); | 
| - // Analyze the bytecodes to find the loop ranges and nesting. No other | 
| - // methods in this class return valid information until this has been called. | 
| - void Analyze(); | 
| + // Analyze the bytecodes to find the loop ranges, loop nesting, loop | 
| + // assignments and liveness, under the assumption that there is an OSR bailout | 
| + // at {osr_bailout_id}. | 
| + // | 
| + // No other methods in this class return valid information until this has been | 
| + // called. | 
| + void Analyze(BailoutId osr_bailout_id); | 
| // Return true if the given offset is a loop header | 
| bool IsLoopHeader(int offset) const; | 
| // Get the loop header offset of the containing loop for arbitrary | 
| // {offset}, or -1 if the {offset} is not inside any loop. | 
| int GetLoopOffsetFor(int offset) const; | 
| - // Gets the loop header offset of the parent loop of the loop header | 
| - // at {header_offset}, or -1 for outer-most loops. | 
| - int GetParentLoopFor(int header_offset) const; | 
| + // Get the loop info of the loop header at {header_offset}. | 
| + const LoopInfo& GetLoopInfoFor(int header_offset) const; | 
| // Gets the in-liveness for the bytecode at {offset}. | 
| const BytecodeLivenessState* GetInLivenessFor(int offset) const; | 
| @@ -45,28 +89,32 @@ class V8_EXPORT_PRIVATE BytecodeAnalysis BASE_EMBEDDED { | 
| std::ostream& PrintLivenessTo(std::ostream& os) const; | 
| private: | 
| - void PushLoop(int loop_header, int loop_end); | 
| + struct LoopStackEntry { | 
| + int header_offset; | 
| + LoopInfo* loop_info; | 
| + }; | 
| -#if DEBUG | 
| - bool LivenessIsValid(); | 
| -#endif | 
| - | 
| - Zone* zone() const { return zone_; } | 
| - Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; } | 
| - | 
| - private: | 
| Handle<BytecodeArray> bytecode_array_; | 
| bool do_liveness_analysis_; | 
| Zone* zone_; | 
| - ZoneStack<int> loop_stack_; | 
| + ZoneStack<LoopStackEntry> loop_stack_; | 
| ZoneVector<int> loop_end_index_queue_; | 
| ZoneMap<int, int> end_to_header_; | 
| - ZoneMap<int, int> header_to_parent_; | 
| + ZoneMap<int, LoopInfo> header_to_info_; | 
| BytecodeLivenessMap liveness_map_; | 
| 
 
rmcilroy
2016/12/14 10:27:55
nit - fields go below private functions.
 
Leszek Swirski
2016/12/14 14:42:19
No idea why I moved these. Done.
 
 | 
| + void PushLoop(int loop_header, int loop_end); | 
| + | 
| +#if DEBUG | 
| + bool LivenessIsValid(); | 
| +#endif | 
| + | 
| + Zone* zone() const { return zone_; } | 
| + Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; } | 
| + | 
| DISALLOW_COPY_AND_ASSIGN(BytecodeAnalysis); | 
| }; |