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

Side by Side Diff: src/interpreter/bytecode-array-reverse-iterator.cc

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/interpreter/bytecode-array-reverse-iterator.h ('k') | src/v8.gyp » ('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 2015 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 #include "src/interpreter/bytecode-array-reverse-iterator.h"
6 #include "src/objects-inl.h"
7
8 namespace v8 {
9 namespace internal {
10 namespace interpreter {
11
12 BytecodeArrayReverseIterator::BytecodeArrayReverseIterator(
13 Handle<BytecodeArray> bytecode_array, Zone* zone)
14 : BytecodeArrayAccessor(bytecode_array, 0), offsets_(zone) {
15 // Run forwards through the bytecode array to determine the offset of each
16 // bytecode.
17 while (current_offset() < bytecode_array->length()) {
18 offsets_.push_back(current_offset());
19 SetOffset(current_offset() + current_bytecode_size());
20 }
21 Reset();
22 }
23
24 void BytecodeArrayReverseIterator::Advance() {
25 it_offsets_++;
26 UpdateOffsetFromIterator();
27 }
28
29 void BytecodeArrayReverseIterator::Reset() {
30 it_offsets_ = offsets_.rbegin();
31 UpdateOffsetFromIterator();
32 }
33
34 bool BytecodeArrayReverseIterator::done() const {
35 return it_offsets_ == offsets_.rend();
36 }
37
38 void BytecodeArrayReverseIterator::UpdateOffsetFromIterator() {
39 if (it_offsets_ != offsets_.rend()) {
40 SetOffset(*it_offsets_);
41 }
42 }
43
44 } // namespace interpreter
45 } // namespace internal
46 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-reverse-iterator.h ('k') | src/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698