Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: src/interpreter/bytecode-array-random-iterator.h

Issue 2536653003: [ignition] Rewrite reverse iterator as random iterator (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/bytecode-analysis.cc ('k') | src/interpreter/bytecode-array-random-iterator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 ++current_index_;
24 UpdateOffsetFromIndex();
25 return *this;
26 }
27 BytecodeArrayRandomIterator& operator--() {
28 --current_index_;
29 UpdateOffsetFromIndex();
30 return *this;
31 }
32
33 BytecodeArrayRandomIterator& operator+=(int offset) {
34 current_index_ += offset;
35 UpdateOffsetFromIndex();
36 return *this;
37 }
38
39 BytecodeArrayRandomIterator& operator-=(int offset) {
40 current_index_ -= offset;
41 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 current_index_ = index;
51 UpdateOffsetFromIndex();
52 }
53 void GoToStart() {
54 current_index_ = 0;
55 UpdateOffsetFromIndex();
56 }
57 void GoToEnd() {
58 DCHECK_LT(offsets_.size() - 1, static_cast<size_t>(INT_MAX));
59 current_index_ = static_cast<int>(offsets_.size() - 1);
60 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_
OLDNEW
« no previous file with comments | « src/compiler/bytecode-analysis.cc ('k') | src/interpreter/bytecode-array-random-iterator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698