Commit e278b6d7 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[cleanup] Replace redundant BytecodeArrayIterator class

It had essentially become a synonym for BytecodeArrayAccessor.
This removes the BytecodeArrayIterator class and renames
BytecodeArrayAccessor to BytecodeArrayIterator.

Change-Id: I79cf8574f3c8804822f90c8f921c17ca7ab85f48
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2715523
Auto-Submit: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73005}
parent 26902dbc
......@@ -2970,8 +2970,6 @@ v8_source_set("v8_base_without_compiler") {
"src/init/v8.cc",
"src/init/v8.h",
"src/interpreter/block-coverage-builder.h",
"src/interpreter/bytecode-array-accessor.cc",
"src/interpreter/bytecode-array-accessor.h",
"src/interpreter/bytecode-array-builder.cc",
"src/interpreter/bytecode-array-builder.h",
"src/interpreter/bytecode-array-iterator.cc",
......
......@@ -36,7 +36,6 @@ include_rules = [
"+src/heap/conservative-stack-visitor.h",
"-src/inspector",
"-src/interpreter",
"+src/interpreter/bytecode-array-accessor.h",
"+src/interpreter/bytecode-array-iterator.h",
"+src/interpreter/bytecode-array-random-iterator.h",
"+src/interpreter/bytecode-decoder.h",
......
This diff is collapsed.
......@@ -170,7 +170,7 @@ class BaselineCompiler {
INTRINSICS_LIST(DECLARE_VISITOR)
#undef DECLARE_VISITOR
const interpreter::BytecodeArrayAccessor& accessor() { return iterator_; }
const interpreter::BytecodeArrayIterator& iterator() { return iterator_; }
Isolate* isolate_;
RuntimeCallStats* stats_;
......
......@@ -6,8 +6,8 @@
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-array-random-iterator.h"
#include "src/utils/ostreams.h"
#include "src/objects/objects-inl.h"
#include "src/utils/ostreams.h"
namespace v8 {
namespace internal {
......@@ -98,14 +98,14 @@ BytecodeAnalysis::BytecodeAnalysis(Handle<BytecodeArray> bytecode_array,
namespace {
void UpdateInLiveness(Bytecode bytecode, BytecodeLivenessState* in_liveness,
const interpreter::BytecodeArrayAccessor& accessor) {
const interpreter::BytecodeArrayIterator& iterator) {
int num_operands = Bytecodes::NumberOfOperands(bytecode);
const OperandType* operand_types = Bytecodes::GetOperandTypes(bytecode);
// Special case Suspend and Resume to just pass through liveness.
if (bytecode == Bytecode::kSuspendGenerator) {
// The generator object has to be live.
in_liveness->MarkRegisterLive(accessor.GetRegisterOperand(0).index());
in_liveness->MarkRegisterLive(iterator.GetRegisterOperand(0).index());
// Suspend additionally reads and returns the accumulator
DCHECK(Bytecodes::ReadsAccumulator(bytecode));
in_liveness->MarkAccumulatorLive();
......@@ -113,7 +113,7 @@ void UpdateInLiveness(Bytecode bytecode, BytecodeLivenessState* in_liveness,
}
if (bytecode == Bytecode::kResumeGenerator) {
// The generator object has to be live.
in_liveness->MarkRegisterLive(accessor.GetRegisterOperand(0).index());
in_liveness->MarkRegisterLive(iterator.GetRegisterOperand(0).index());
return;
}
......@@ -123,15 +123,15 @@ void UpdateInLiveness(Bytecode bytecode, BytecodeLivenessState* in_liveness,
for (int i = 0; i < num_operands; ++i) {
switch (operand_types[i]) {
case OperandType::kRegOut: {
interpreter::Register r = accessor.GetRegisterOperand(i);
interpreter::Register r = iterator.GetRegisterOperand(i);
if (!r.is_parameter()) {
in_liveness->MarkRegisterDead(r.index());
}
break;
}
case OperandType::kRegOutList: {
interpreter::Register r = accessor.GetRegisterOperand(i++);
uint32_t reg_count = accessor.GetRegisterCountOperand(i);
interpreter::Register r = iterator.GetRegisterOperand(i++);
uint32_t reg_count = iterator.GetRegisterCountOperand(i);
if (!r.is_parameter()) {
for (uint32_t j = 0; j < reg_count; ++j) {
DCHECK(!interpreter::Register(r.index() + j).is_parameter());
......@@ -141,7 +141,7 @@ void UpdateInLiveness(Bytecode bytecode, BytecodeLivenessState* in_liveness,
break;
}
case OperandType::kRegOutPair: {
interpreter::Register r = accessor.GetRegisterOperand(i);
interpreter::Register r = iterator.GetRegisterOperand(i);
if (!r.is_parameter()) {
DCHECK(!interpreter::Register(r.index() + 1).is_parameter());
in_liveness->MarkRegisterDead(r.index());
......@@ -150,7 +150,7 @@ void UpdateInLiveness(Bytecode bytecode, BytecodeLivenessState* in_liveness,
break;
}
case OperandType::kRegOutTriple: {
interpreter::Register r = accessor.GetRegisterOperand(i);
interpreter::Register r = iterator.GetRegisterOperand(i);
if (!r.is_parameter()) {
DCHECK(!interpreter::Register(r.index() + 1).is_parameter());
DCHECK(!interpreter::Register(r.index() + 2).is_parameter());
......@@ -177,14 +177,14 @@ void UpdateInLiveness(Bytecode bytecode, BytecodeLivenessState* in_liveness,
for (int i = 0; i < num_operands; ++i) {
switch (operand_types[i]) {
case OperandType::kReg: {
interpreter::Register r = accessor.GetRegisterOperand(i);
interpreter::Register r = iterator.GetRegisterOperand(i);
if (!r.is_parameter()) {
in_liveness->MarkRegisterLive(r.index());
}
break;
}
case OperandType::kRegPair: {
interpreter::Register r = accessor.GetRegisterOperand(i);
interpreter::Register r = iterator.GetRegisterOperand(i);
if (!r.is_parameter()) {
DCHECK(!interpreter::Register(r.index() + 1).is_parameter());
in_liveness->MarkRegisterLive(r.index());
......@@ -193,8 +193,8 @@ void UpdateInLiveness(Bytecode bytecode, BytecodeLivenessState* in_liveness,
break;
}
case OperandType::kRegList: {
interpreter::Register r = accessor.GetRegisterOperand(i++);
uint32_t reg_count = accessor.GetRegisterCountOperand(i);
interpreter::Register r = iterator.GetRegisterOperand(i++);
uint32_t reg_count = iterator.GetRegisterCountOperand(i);
if (!r.is_parameter()) {
for (uint32_t j = 0; j < reg_count; ++j) {
DCHECK(!interpreter::Register(r.index() + j).is_parameter());
......@@ -212,10 +212,10 @@ void UpdateInLiveness(Bytecode bytecode, BytecodeLivenessState* in_liveness,
void UpdateOutLiveness(Bytecode bytecode, BytecodeLivenessState* out_liveness,
BytecodeLivenessState* next_bytecode_in_liveness,
const interpreter::BytecodeArrayAccessor& accessor,
const interpreter::BytecodeArrayIterator& iterator,
Handle<BytecodeArray> bytecode_array,
const BytecodeLivenessMap& liveness_map) {
int current_offset = accessor.current_offset();
int current_offset = iterator.current_offset();
// Special case Suspend and Resume to just pass through liveness.
if (bytecode == Bytecode::kSuspendGenerator ||
......@@ -227,10 +227,10 @@ void UpdateOutLiveness(Bytecode bytecode, BytecodeLivenessState* out_liveness,
// Update from jump target (if any). Skip loops, we update these manually in
// the liveness iterations.
if (Bytecodes::IsForwardJump(bytecode)) {
int target_offset = accessor.GetJumpTargetOffset();
int target_offset = iterator.GetJumpTargetOffset();
out_liveness->Union(*liveness_map.GetInLiveness(target_offset));
} else if (Bytecodes::IsSwitch(bytecode)) {
for (const auto& entry : accessor.GetJumpTableTargetOffsets()) {
for (const auto& entry : iterator.GetJumpTableTargetOffsets()) {
out_liveness->Union(*liveness_map.GetInLiveness(entry.target_offset));
}
}
......@@ -272,40 +272,40 @@ void UpdateOutLiveness(Bytecode bytecode, BytecodeLivenessState* out_liveness,
void UpdateLiveness(Bytecode bytecode, BytecodeLiveness const& liveness,
BytecodeLivenessState** next_bytecode_in_liveness,
const interpreter::BytecodeArrayAccessor& accessor,
const interpreter::BytecodeArrayIterator& iterator,
Handle<BytecodeArray> bytecode_array,
const BytecodeLivenessMap& liveness_map) {
UpdateOutLiveness(bytecode, liveness.out, *next_bytecode_in_liveness,
accessor, bytecode_array, liveness_map);
iterator, bytecode_array, liveness_map);
liveness.in->CopyFrom(*liveness.out);
UpdateInLiveness(bytecode, liveness.in, accessor);
UpdateInLiveness(bytecode, liveness.in, iterator);
*next_bytecode_in_liveness = liveness.in;
}
void UpdateAssignments(Bytecode bytecode, BytecodeLoopAssignments* assignments,
const interpreter::BytecodeArrayAccessor& accessor) {
const interpreter::BytecodeArrayIterator& iterator) {
int num_operands = Bytecodes::NumberOfOperands(bytecode);
const OperandType* operand_types = Bytecodes::GetOperandTypes(bytecode);
for (int i = 0; i < num_operands; ++i) {
switch (operand_types[i]) {
case OperandType::kRegOut: {
assignments->Add(accessor.GetRegisterOperand(i));
assignments->Add(iterator.GetRegisterOperand(i));
break;
}
case OperandType::kRegOutList: {
interpreter::Register r = accessor.GetRegisterOperand(i++);
uint32_t reg_count = accessor.GetRegisterCountOperand(i);
interpreter::Register r = iterator.GetRegisterOperand(i++);
uint32_t reg_count = iterator.GetRegisterCountOperand(i);
assignments->AddList(r, reg_count);
break;
}
case OperandType::kRegOutPair: {
assignments->AddList(accessor.GetRegisterOperand(i), 2);
assignments->AddList(iterator.GetRegisterOperand(i), 2);
break;
}
case OperandType::kRegOutTriple: {
assignments->AddList(accessor.GetRegisterOperand(i), 3);
assignments->AddList(iterator.GetRegisterOperand(i), 3);
break;
}
default:
......@@ -778,14 +778,14 @@ bool BytecodeAnalysis::ResumeJumpTargetLeavesResolveSuspendIds(
valid = false;
} else {
// Make sure we're resuming to a Resume bytecode
interpreter::BytecodeArrayAccessor accessor(bytecode_array(),
interpreter::BytecodeArrayIterator iterator(bytecode_array(),
target.target_offset());
if (accessor.current_bytecode() != Bytecode::kResumeGenerator) {
if (iterator.current_bytecode() != Bytecode::kResumeGenerator) {
PrintF(stderr,
"Expected resume target for id %d, offset %d, to be "
"ResumeGenerator, but found %s\n",
target.suspend_id(), target.target_offset(),
Bytecodes::ToString(accessor.current_bytecode()));
Bytecodes::ToString(iterator.current_bytecode()));
valid = false;
}
......
......@@ -807,7 +807,7 @@ class BytecodeArrayRef : public FixedArrayBaseRef {
// NOTE: Concurrent reads of the actual bytecodes as well as the constant pool
// (both immutable) do not go through BytecodeArrayRef but are performed
// directly through the handle by BytecodeArrayAccessor.
// directly through the handle by BytecodeArrayIterator.
int register_count() const;
int parameter_count() const;
......
......@@ -19,7 +19,7 @@
#include "src/handles/persistent-handles.h"
#include "src/heap/local-heap.h"
#include "src/heap/parked-scope.h"
#include "src/interpreter/bytecode-array-accessor.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/objects/code-kind.h"
#include "src/objects/feedback-vector.h"
#include "src/objects/function-kind.h"
......
......@@ -27,7 +27,6 @@
#include "src/handles/global-handles.h"
#include "src/heap/heap-inl.h" // For NextDebuggingId.
#include "src/init/bootstrapper.h"
#include "src/interpreter/bytecode-array-accessor.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/interpreter.h"
#include "src/logging/counters.h"
......@@ -313,7 +312,7 @@ void BreakIterator::SetDebugBreak() {
DCHECK(debug_break_type >= DEBUG_BREAK_SLOT);
Handle<BytecodeArray> bytecode_array(debug_info_->DebugBytecodeArray(),
isolate());
interpreter::BytecodeArrayAccessor(bytecode_array, code_offset())
interpreter::BytecodeArrayIterator(bytecode_array, code_offset())
.ApplyDebugBreak();
}
......@@ -338,12 +337,12 @@ BreakLocation BreakIterator::GetBreakLocation() {
// bytecode array, and we'll read the actual generator object off the
// interpreter stack frame in GetGeneratorObjectForSuspendedFrame.
BytecodeArray bytecode_array = debug_info_->OriginalBytecodeArray();
interpreter::BytecodeArrayAccessor accessor(
interpreter::BytecodeArrayIterator iterator(
handle(bytecode_array, isolate()), code_offset());
DCHECK_EQ(accessor.current_bytecode(),
DCHECK_EQ(iterator.current_bytecode(),
interpreter::Bytecode::kSuspendGenerator);
interpreter::Register generator_obj_reg = accessor.GetRegisterOperand(0);
interpreter::Register generator_obj_reg = iterator.GetRegisterOperand(0);
generator_object_reg_index = generator_obj_reg.index();
}
return BreakLocation(code, type, code_offset(), position_,
......@@ -2528,17 +2527,17 @@ bool Debug::PerformSideEffectCheckAtBytecode(InterpretedFrame* frame) {
SharedFunctionInfo shared = frame->function().shared();
BytecodeArray bytecode_array = shared.GetBytecodeArray(isolate_);
int offset = frame->GetBytecodeOffset();
interpreter::BytecodeArrayAccessor bytecode_accessor(
interpreter::BytecodeArrayIterator bytecode_iterator(
handle(bytecode_array, isolate_), offset);
Bytecode bytecode = bytecode_accessor.current_bytecode();
Bytecode bytecode = bytecode_iterator.current_bytecode();
interpreter::Register reg;
switch (bytecode) {
case Bytecode::kStaCurrentContextSlot:
reg = interpreter::Register::current_context();
break;
default:
reg = bytecode_accessor.GetRegisterOperand(0);
reg = bytecode_iterator.GetRegisterOperand(0);
break;
}
Handle<Object> object =
......
This diff is collapsed.
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_INTERPRETER_BYTECODE_ARRAY_ACCESSOR_H_
#define V8_INTERPRETER_BYTECODE_ARRAY_ACCESSOR_H_
#include <memory>
#include "src/base/optional.h"
#include "src/common/globals.h"
#include "src/handles/handles.h"
#include "src/interpreter/bytecode-register.h"
#include "src/interpreter/bytecodes.h"
#include "src/objects/objects.h"
#include "src/objects/smi.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {
class BytecodeArray;
namespace interpreter {
class BytecodeArrayAccessor;
struct V8_EXPORT_PRIVATE JumpTableTargetOffset {
int case_value;
int target_offset;
};
class V8_EXPORT_PRIVATE JumpTableTargetOffsets final {
public:
// Minimal iterator implementation for use in ranged-for.
class V8_EXPORT_PRIVATE iterator final {
public:
iterator(int case_value, int table_offset, int table_end,
const BytecodeArrayAccessor* accessor);
JumpTableTargetOffset operator*();
iterator& operator++();
bool operator!=(const iterator& other);
private:
void UpdateAndAdvanceToValid();
const BytecodeArrayAccessor* accessor_;
Smi current_;
int index_;
int table_offset_;
int table_end_;
};
JumpTableTargetOffsets(const BytecodeArrayAccessor* accessor, int table_start,
int table_size, int case_value_base);
iterator begin() const;
iterator end() const;
int size() const;
private:
const BytecodeArrayAccessor* accessor_;
int table_start_;
int table_size_;
int case_value_base_;
};
class V8_EXPORT_PRIVATE BytecodeArrayAccessor {
public:
BytecodeArrayAccessor(Handle<BytecodeArray> bytecode_array,
int initial_offset);
~BytecodeArrayAccessor();
BytecodeArrayAccessor(const BytecodeArrayAccessor&) = delete;
BytecodeArrayAccessor& operator=(const BytecodeArrayAccessor&) = delete;
inline void Advance() {
cursor_ += Bytecodes::Size(current_bytecode(), current_operand_scale());
UpdateOperandScale();
}
void SetOffset(int offset);
void Reset() { SetOffset(0); }
void ApplyDebugBreak();
inline Bytecode current_bytecode() const {
DCHECK(!done());
uint8_t current_byte = *cursor_;
Bytecode current_bytecode = Bytecodes::FromByte(current_byte);
DCHECK(!Bytecodes::IsPrefixScalingBytecode(current_bytecode));
return current_bytecode;
}
int current_bytecode_size() const;
int current_offset() const {
return static_cast<int>(cursor_ - start_ - prefix_size_);
}
OperandScale current_operand_scale() const { return operand_scale_; }
Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
uint32_t GetFlagOperand(int operand_index) const;
uint32_t GetUnsignedImmediateOperand(int operand_index) const;
int32_t GetImmediateOperand(int operand_index) const;
uint32_t GetIndexOperand(int operand_index) const;
FeedbackSlot GetSlotOperand(int operand_index) const;
Register GetReceiver() const;
Register GetParameter(int parameter_index) const;
uint32_t GetRegisterCountOperand(int operand_index) const;
Register GetRegisterOperand(int operand_index) const;
std::pair<Register, Register> GetRegisterPairOperand(int operand_index) const;
RegisterList GetRegisterListOperand(int operand_index) const;
int GetRegisterOperandRange(int operand_index) const;
Runtime::FunctionId GetRuntimeIdOperand(int operand_index) const;
Runtime::FunctionId GetIntrinsicIdOperand(int operand_index) const;
uint32_t GetNativeContextIndexOperand(int operand_index) const;
template <typename LocalIsolate>
Handle<Object> GetConstantAtIndex(int offset, LocalIsolate* isolate) const;
bool IsConstantAtIndexSmi(int offset) const;
Smi GetConstantAtIndexAsSmi(int offset) const;
template <typename LocalIsolate>
Handle<Object> GetConstantForIndexOperand(int operand_index,
LocalIsolate* isolate) const;
// Returns the relative offset of the branch target at the current bytecode.
// It is an error to call this method if the bytecode is not for a jump or
// conditional jump. Returns a negative offset for backward jumps.
int GetRelativeJumpTargetOffset() const;
// Returns the absolute offset of the branch target at the current bytecode.
// It is an error to call this method if the bytecode is not for a jump or
// conditional jump.
int GetJumpTargetOffset() const;
// Returns an iterator over the absolute offsets of the targets of the current
// switch bytecode's jump table. It is an error to call this method if the
// bytecode is not a switch.
JumpTableTargetOffsets GetJumpTableTargetOffsets() const;
// Returns the absolute offset of the bytecode at the given relative offset
// from the current bytecode.
int GetAbsoluteOffset(int relative_offset) const;
std::ostream& PrintTo(std::ostream& os) const;
static void UpdatePointersCallback(void* accessor) {
reinterpret_cast<BytecodeArrayAccessor*>(accessor)->UpdatePointers();
}
void UpdatePointers();
inline bool done() const { return cursor_ >= end_; }
private:
uint32_t GetUnsignedOperand(int operand_index,
OperandType operand_type) const;
int32_t GetSignedOperand(int operand_index, OperandType operand_type) const;
inline void UpdateOperandScale() {
if (done()) return;
uint8_t current_byte = *cursor_;
Bytecode current_bytecode = Bytecodes::FromByte(current_byte);
if (Bytecodes::IsPrefixScalingBytecode(current_bytecode)) {
operand_scale_ =
Bytecodes::PrefixBytecodeToOperandScale(current_bytecode);
++cursor_;
prefix_size_ = 1;
} else {
operand_scale_ = OperandScale::kSingle;
prefix_size_ = 0;
}
}
Handle<BytecodeArray> bytecode_array_;
uint8_t* start_;
uint8_t* end_;
// The cursor always points to the active bytecode. If there's a prefix, the
// prefix is at (cursor - 1).
uint8_t* cursor_;
OperandScale operand_scale_;
int prefix_size_;
LocalHeap* const local_heap_;
};
} // namespace interpreter
} // namespace internal
} // namespace v8
#endif // V8_INTERPRETER_BYTECODE_ARRAY_ACCESSOR_H_
This diff is collapsed.
......@@ -7,19 +7,177 @@
#include <memory>
#include "src/interpreter/bytecode-array-accessor.h"
#include "src/base/optional.h"
#include "src/common/globals.h"
#include "src/handles/handles.h"
#include "src/interpreter/bytecode-register.h"
#include "src/interpreter/bytecodes.h"
#include "src/objects/objects.h"
#include "src/objects/smi.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {
class BytecodeArray;
namespace interpreter {
class V8_EXPORT_PRIVATE BytecodeArrayIterator final
: public BytecodeArrayAccessor {
class BytecodeArrayIterator;
struct V8_EXPORT_PRIVATE JumpTableTargetOffset {
int case_value;
int target_offset;
};
class V8_EXPORT_PRIVATE JumpTableTargetOffsets final {
public:
// Minimal iterator implementation for use in ranged-for.
class V8_EXPORT_PRIVATE iterator final {
public:
iterator(int case_value, int table_offset, int table_end,
const BytecodeArrayIterator* iterator);
JumpTableTargetOffset operator*();
iterator& operator++();
bool operator!=(const iterator& other);
private:
void UpdateAndAdvanceToValid();
const BytecodeArrayIterator* iterator_;
Smi current_;
int index_;
int table_offset_;
int table_end_;
};
JumpTableTargetOffsets(const BytecodeArrayIterator* iterator, int table_start,
int table_size, int case_value_base);
iterator begin() const;
iterator end() const;
int size() const;
private:
const BytecodeArrayIterator* iterator_;
int table_start_;
int table_size_;
int case_value_base_;
};
class V8_EXPORT_PRIVATE BytecodeArrayIterator {
public:
explicit BytecodeArrayIterator(Handle<BytecodeArray> array);
BytecodeArrayIterator(Handle<BytecodeArray> bytecode_array,
int initial_offset = 0);
~BytecodeArrayIterator();
BytecodeArrayIterator(const BytecodeArrayIterator&) = delete;
BytecodeArrayIterator& operator=(const BytecodeArrayIterator&) = delete;
inline void Advance() {
cursor_ += Bytecodes::Size(current_bytecode(), current_operand_scale());
UpdateOperandScale();
}
void SetOffset(int offset);
void Reset() { SetOffset(0); }
void ApplyDebugBreak();
inline Bytecode current_bytecode() const {
DCHECK(!done());
uint8_t current_byte = *cursor_;
Bytecode current_bytecode = Bytecodes::FromByte(current_byte);
DCHECK(!Bytecodes::IsPrefixScalingBytecode(current_bytecode));
return current_bytecode;
}
int current_bytecode_size() const;
int current_offset() const {
return static_cast<int>(cursor_ - start_ - prefix_size_);
}
OperandScale current_operand_scale() const { return operand_scale_; }
Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
uint32_t GetFlagOperand(int operand_index) const;
uint32_t GetUnsignedImmediateOperand(int operand_index) const;
int32_t GetImmediateOperand(int operand_index) const;
uint32_t GetIndexOperand(int operand_index) const;
FeedbackSlot GetSlotOperand(int operand_index) const;
Register GetReceiver() const;
Register GetParameter(int parameter_index) const;
uint32_t GetRegisterCountOperand(int operand_index) const;
Register GetRegisterOperand(int operand_index) const;
std::pair<Register, Register> GetRegisterPairOperand(int operand_index) const;
RegisterList GetRegisterListOperand(int operand_index) const;
int GetRegisterOperandRange(int operand_index) const;
Runtime::FunctionId GetRuntimeIdOperand(int operand_index) const;
Runtime::FunctionId GetIntrinsicIdOperand(int operand_index) const;
uint32_t GetNativeContextIndexOperand(int operand_index) const;
template <typename LocalIsolate>
Handle<Object> GetConstantAtIndex(int offset, LocalIsolate* isolate) const;
bool IsConstantAtIndexSmi(int offset) const;
Smi GetConstantAtIndexAsSmi(int offset) const;
template <typename LocalIsolate>
Handle<Object> GetConstantForIndexOperand(int operand_index,
LocalIsolate* isolate) const;
// Returns the relative offset of the branch target at the current bytecode.
// It is an error to call this method if the bytecode is not for a jump or
// conditional jump. Returns a negative offset for backward jumps.
int GetRelativeJumpTargetOffset() const;
// Returns the absolute offset of the branch target at the current bytecode.
// It is an error to call this method if the bytecode is not for a jump or
// conditional jump.
int GetJumpTargetOffset() const;
// Returns an iterator over the absolute offsets of the targets of the current
// switch bytecode's jump table. It is an error to call this method if the
// bytecode is not a switch.
JumpTableTargetOffsets GetJumpTableTargetOffsets() const;
// Returns the absolute offset of the bytecode at the given relative offset
// from the current bytecode.
int GetAbsoluteOffset(int relative_offset) const;
std::ostream& PrintTo(std::ostream& os) const;
static void UpdatePointersCallback(void* iterator) {
reinterpret_cast<BytecodeArrayIterator*>(iterator)->UpdatePointers();
}
void UpdatePointers();
inline bool done() const { return cursor_ >= end_; }
private:
uint32_t GetUnsignedOperand(int operand_index,
OperandType operand_type) const;
int32_t GetSignedOperand(int operand_index, OperandType operand_type) const;
inline void UpdateOperandScale() {
if (done()) return;
uint8_t current_byte = *cursor_;
Bytecode current_bytecode = Bytecodes::FromByte(current_byte);
if (Bytecodes::IsPrefixScalingBytecode(current_bytecode)) {
operand_scale_ =
Bytecodes::PrefixBytecodeToOperandScale(current_bytecode);
++cursor_;
prefix_size_ = 1;
} else {
operand_scale_ = OperandScale::kSingle;
prefix_size_ = 0;
}
}
Handle<BytecodeArray> bytecode_array_;
uint8_t* start_;
uint8_t* end_;
// The cursor always points to the active bytecode. If there's a prefix, the
// prefix is at (cursor - 1).
uint8_t* cursor_;
OperandScale operand_scale_;
int prefix_size_;
LocalHeap* const local_heap_;
};
} // namespace interpreter
......
......@@ -12,7 +12,7 @@ namespace interpreter {
BytecodeArrayRandomIterator::BytecodeArrayRandomIterator(
Handle<BytecodeArray> bytecode_array, Zone* zone)
: BytecodeArrayAccessor(bytecode_array, 0), offsets_(zone) {
: BytecodeArrayIterator(bytecode_array, 0), offsets_(zone) {
offsets_.reserve(bytecode_array->length() / 2);
Initialize();
}
......
......@@ -7,7 +7,7 @@
#include <memory>
#include "src/interpreter/bytecode-array-accessor.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/zone/zone-containers.h"
#include "src/zone/zone.h"
......@@ -16,7 +16,7 @@ namespace internal {
namespace interpreter {
class V8_EXPORT_PRIVATE BytecodeArrayRandomIterator final
: public BytecodeArrayAccessor {
: public BytecodeArrayIterator {
public:
BytecodeArrayRandomIterator(Handle<BytecodeArray> bytecode_array, Zone* zone);
......
......@@ -157,7 +157,7 @@ class RegisterList {
friend class BytecodeDecoder;
friend class InterpreterTester;
friend class BytecodeUtils;
friend class BytecodeArrayAccessor;
friend class BytecodeArrayIterator;
RegisterList(int first_reg_index, int register_count)
: first_reg_index_(first_reg_index), register_count_(register_count) {}
......
......@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <iomanip>
#include "src/execution/isolate-utils.h"
#include "src/objects/code.h"
#include <iomanip>
#include "src/codegen/assembler-inl.h"
#include "src/codegen/cpu-features.h"
#include "src/codegen/reloc-info.h"
#include "src/codegen/safepoint-table.h"
#include "src/deoptimizer/deoptimizer.h"
#include "src/execution/isolate-utils.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-decoder.h"
#include "src/interpreter/interpreter.h"
......
......@@ -17,7 +17,7 @@
#include "src/execution/frames-inl.h"
#include "src/execution/isolate-inl.h"
#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop.
#include "src/interpreter/bytecode-array-accessor.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecodes.h"
#include "src/interpreter/interpreter.h"
#include "src/logging/counters.h"
......
......@@ -41,8 +41,8 @@ void AdvanceToOffsetForTracing(
}
void PrintRegisters(UnoptimizedFrame* frame, std::ostream& os, bool is_input,
interpreter::BytecodeArrayAccessor&
bytecode_accessor, // NOLINT(runtime/references)
interpreter::BytecodeArrayIterator&
bytecode_iterator, // NOLINT(runtime/references)
Handle<Object> accumulator) {
static const char kAccumulator[] = "accumulator";
static const int kRegFieldWidth = static_cast<int>(sizeof(kAccumulator) - 1);
......@@ -54,7 +54,7 @@ void PrintRegisters(UnoptimizedFrame* frame, std::ostream& os, bool is_input,
os << (is_input ? kInputColourCode : kOutputColourCode);
}
interpreter::Bytecode bytecode = bytecode_accessor.current_bytecode();
interpreter::Bytecode bytecode = bytecode_iterator.current_bytecode();
// Print accumulator.
if ((is_input && interpreter::Bytecodes::ReadsAccumulator(bytecode)) ||
......@@ -75,14 +75,14 @@ void PrintRegisters(UnoptimizedFrame* frame, std::ostream& os, bool is_input,
: interpreter::Bytecodes::IsRegisterOutputOperandType(operand_type);
if (should_print) {
interpreter::Register first_reg =
bytecode_accessor.GetRegisterOperand(operand_index);
int range = bytecode_accessor.GetRegisterOperandRange(operand_index);
bytecode_iterator.GetRegisterOperand(operand_index);
int range = bytecode_iterator.GetRegisterOperandRange(operand_index);
for (int reg_index = first_reg.index();
reg_index < first_reg.index() + range; reg_index++) {
Object reg_object = frame->ReadInterpreterRegister(reg_index);
os << " [ " << std::setw(kRegFieldWidth)
<< interpreter::Register(reg_index).ToString(
bytecode_accessor.bytecode_array()->parameter_count())
bytecode_iterator.bytecode_array()->parameter_count())
<< kArrowDirection;
reg_object.ShortPrint(os);
os << " ]" << std::endl;
......
......@@ -5,7 +5,6 @@
#include <fstream>
#include "src/init/v8.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-generator.h"
#include "src/interpreter/interpreter.h"
......
......@@ -4,14 +4,13 @@
#include <tuple>
#include "src/init/v8.h"
#include "src/api/api-inl.h"
#include "src/base/overflowing-math.h"
#include "src/codegen/compiler.h"
#include "src/execution/execution.h"
#include "src/handles/handles.h"
#include "src/heap/heap-inl.h"
#include "src/init/v8.h"
#include "src/interpreter/bytecode-array-builder.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-flags.h"
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/init/v8.h"
#include "src/compiler/bytecode-analysis.h"
#include "src/init/v8.h"
#include "src/interpreter/bytecode-array-builder.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-decoder.h"
......
......@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <limits>
#include "src/interpreter/bytecode-array-builder.h"
#include "src/init/v8.h"
#include <limits>
#include "src/ast/scopes.h"
#include "src/interpreter/bytecode-array-builder.h"
#include "src/init/v8.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-jump-table.h"
#include "src/interpreter/bytecode-label.h"
......
......@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/init/v8.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/init/v8.h"
#include "src/interpreter/bytecode-array-builder.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/numbers/hash-seed-inl.h"
#include "src/objects/objects-inl.h"
#include "src/objects/smi.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment