LCOV - code coverage report
Current view: top level - src/interpreter - bytecode-array-random-iterator.h (source / functions) Hit Total Coverage
Test: app.info Lines: 14 14 100.0 %
Date: 2019-01-20 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2016 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_INTERPRETER_BYTECODE_ARRAY_RANDOM_ITERATOR_H_
       6             : #define V8_INTERPRETER_BYTECODE_ARRAY_RANDOM_ITERATOR_H_
       7             : 
       8             : #include "src/interpreter/bytecode-array-accessor.h"
       9             : #include "src/zone/zone-containers.h"
      10             : #include "src/zone/zone.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : namespace interpreter {
      15             : 
      16             : class V8_EXPORT_PRIVATE BytecodeArrayRandomIterator final
      17             :     : public BytecodeArrayAccessor {
      18             :  public:
      19             :   explicit BytecodeArrayRandomIterator(Handle<BytecodeArray> bytecode_array,
      20             :                                        Zone* zone);
      21             : 
      22             :   BytecodeArrayRandomIterator& operator++() {
      23          24 :     ++current_index_;
      24          24 :     UpdateOffsetFromIndex();
      25             :     return *this;
      26             :   }
      27             :   BytecodeArrayRandomIterator& operator--() {
      28    17559364 :     --current_index_;
      29    17559364 :     UpdateOffsetFromIndex();
      30             :     return *this;
      31             :   }
      32             : 
      33             :   BytecodeArrayRandomIterator& operator+=(int offset) {
      34           1 :     current_index_ += offset;
      35           1 :     UpdateOffsetFromIndex();
      36             :     return *this;
      37             :   }
      38             : 
      39             :   BytecodeArrayRandomIterator& operator-=(int offset) {
      40           1 :     current_index_ -= offset;
      41           1 :     UpdateOffsetFromIndex();
      42             :     return *this;
      43             :   }
      44             : 
      45             :   int current_index() const { return current_index_; }
      46             : 
      47             :   size_t size() const { return offsets_.size(); }
      48             : 
      49             :   void GoToIndex(int index) {
      50       60098 :     current_index_ = index;
      51       60098 :     UpdateOffsetFromIndex();
      52             :   }
      53             :   void GoToStart() {
      54      523153 :     current_index_ = 0;
      55      523153 :     UpdateOffsetFromIndex();
      56             :   }
      57             :   void GoToEnd() {
      58             :     DCHECK_LT(offsets_.size() - 1, static_cast<size_t>(INT_MAX));
      59     1046290 :     current_index_ = static_cast<int>(offsets_.size() - 1);
      60      523145 :     UpdateOffsetFromIndex();
      61             :   }
      62             : 
      63             :   bool IsValid() const;
      64             : 
      65             :  private:
      66             :   ZoneVector<int> offsets_;
      67             :   int current_index_;
      68             : 
      69             :   void UpdateOffsetFromIndex();
      70             : 
      71             :   DISALLOW_COPY_AND_ASSIGN(BytecodeArrayRandomIterator);
      72             : };
      73             : 
      74             : }  // namespace interpreter
      75             : }  // namespace internal
      76             : }  // namespace v8
      77             : 
      78             : #endif  // V8_INTERPRETER_BYTECODE_ARRAY_RANDOM_ITERATOR_H_

Generated by: LCOV version 1.10