v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
bytecode-array-random-iterator.cc
Go to the documentation of this file.
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-random-iterator.h
"
6
7
#include "
src/objects/objects-inl.h
"
8
9
namespace
v8
{
10
namespace
internal
{
11
namespace
interpreter {
12
13
BytecodeArrayRandomIterator::BytecodeArrayRandomIterator
(
14
Handle<BytecodeArray>
bytecode_array,
Zone
* zone)
15
:
BytecodeArrayIterator
(bytecode_array, 0), offsets_(zone) {
16
offsets_
.
reserve
(
bytecode_array
->length() / 2);
17
Initialize
();
18
}
19
20
void
BytecodeArrayRandomIterator::Initialize
() {
21
// Run forwards through the bytecode array to determine the offset of each
22
// bytecode.
23
while
(!
done
()) {
24
offsets_
.
push_back
(
current_offset
());
25
Advance
();
26
}
27
GoToStart
();
28
}
29
30
bool
BytecodeArrayRandomIterator::IsValid
()
const
{
31
return
current_index_
>= 0 &&
32
static_cast<
size_t
>
(
current_index_
) <
offsets_
.
size
();
33
}
34
35
void
BytecodeArrayRandomIterator::UpdateOffsetFromIndex
() {
36
if
(
IsValid
()) {
37
SetOffsetUnchecked
(
offsets_
[
current_index_
]);
38
}
39
}
40
41
}
// namespace interpreter
42
}
// namespace internal
43
}
// namespace v8
bytecode-array-random-iterator.h
v8::internal::Handle
Definition
handles.h:149
v8::internal::ZoneVector::reserve
void reserve(size_t new_cap)
Definition
zone-containers.h:241
v8::internal::ZoneVector::size
size_t size() const
Definition
zone-containers.h:238
v8::internal::ZoneVector::push_back
void push_back(const T &value)
Definition
zone-containers.h:303
v8::internal::Zone
Definition
zone.h:43
v8::internal::interpreter::BytecodeArrayIterator
Definition
bytecode-array-iterator.h:70
v8::internal::interpreter::BytecodeArrayIterator::done
bool done() const
Definition
bytecode-array-iterator.h:179
v8::internal::interpreter::BytecodeArrayIterator::Advance
void Advance()
Definition
bytecode-array-iterator.h:81
v8::internal::interpreter::BytecodeArrayIterator::bytecode_array
DirectHandle< BytecodeArray > bytecode_array() const
Definition
bytecode-array-iterator.h:128
v8::internal::interpreter::BytecodeArrayIterator::current_offset
int current_offset() const
Definition
bytecode-array-iterator.h:113
v8::internal::interpreter::BytecodeArrayIterator::SetOffsetUnchecked
void SetOffsetUnchecked(int offset)
Definition
bytecode-array-iterator.cc:84
v8::internal::interpreter::BytecodeArrayRandomIterator::offsets_
ZoneVector< int > offsets_
Definition
bytecode-array-random-iterator.h:70
v8::internal::interpreter::BytecodeArrayRandomIterator::IsValid
bool IsValid() const
Definition
bytecode-array-random-iterator.cc:30
v8::internal::interpreter::BytecodeArrayRandomIterator::current_index_
int current_index_
Definition
bytecode-array-random-iterator.h:71
v8::internal::interpreter::BytecodeArrayRandomIterator::Initialize
void Initialize()
Definition
bytecode-array-random-iterator.cc:20
v8::internal::interpreter::BytecodeArrayRandomIterator::UpdateOffsetFromIndex
void UpdateOffsetFromIndex()
Definition
bytecode-array-random-iterator.cc:35
v8::internal::interpreter::BytecodeArrayRandomIterator::GoToStart
void GoToStart()
Definition
bytecode-array-random-iterator.h:58
v8::internal::interpreter::BytecodeArrayRandomIterator::BytecodeArrayRandomIterator
BytecodeArrayRandomIterator(Handle< BytecodeArray > bytecode_array, Zone *zone)
Definition
bytecode-array-random-iterator.cc:13
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
objects-inl.h
src
interpreter
bytecode-array-random-iterator.cc
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0