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",
......
......@@ -22,7 +22,6 @@
#include "src/codegen/macro-assembler-inl.h"
#include "src/common/globals.h"
#include "src/execution/frame-constants.h"
#include "src/interpreter/bytecode-array-accessor.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-flags.h"
#include "src/objects/code.h"
......@@ -285,7 +284,7 @@ Handle<Code> BaselineCompiler::Build(Isolate* isolate) {
}
interpreter::Register BaselineCompiler::RegisterOperand(int operand_index) {
return accessor().GetRegisterOperand(operand_index);
return iterator().GetRegisterOperand(operand_index);
}
void BaselineCompiler::LoadRegister(Register output, int operand_index) {
......@@ -299,36 +298,36 @@ void BaselineCompiler::StoreRegister(int operand_index, Register value) {
void BaselineCompiler::StoreRegisterPair(int operand_index, Register val0,
Register val1) {
interpreter::Register reg0, reg1;
std::tie(reg0, reg1) = accessor().GetRegisterPairOperand(operand_index);
std::tie(reg0, reg1) = iterator().GetRegisterPairOperand(operand_index);
__ StoreRegister(reg0, val0);
__ StoreRegister(reg1, val1);
}
template <typename Type>
Handle<Type> BaselineCompiler::Constant(int operand_index) {
return Handle<Type>::cast(
accessor().GetConstantForIndexOperand(operand_index, isolate_));
iterator().GetConstantForIndexOperand(operand_index, isolate_));
}
Smi BaselineCompiler::ConstantSmi(int operand_index) {
return accessor().GetConstantAtIndexAsSmi(operand_index);
return iterator().GetConstantAtIndexAsSmi(operand_index);
}
template <typename Type>
void BaselineCompiler::LoadConstant(Register output, int operand_index) {
__ Move(output, Constant<Type>(operand_index));
}
uint32_t BaselineCompiler::Uint(int operand_index) {
return accessor().GetUnsignedImmediateOperand(operand_index);
return iterator().GetUnsignedImmediateOperand(operand_index);
}
int32_t BaselineCompiler::Int(int operand_index) {
return accessor().GetImmediateOperand(operand_index);
return iterator().GetImmediateOperand(operand_index);
}
uint32_t BaselineCompiler::Index(int operand_index) {
return accessor().GetIndexOperand(operand_index);
return iterator().GetIndexOperand(operand_index);
}
uint32_t BaselineCompiler::Flag(int operand_index) {
return accessor().GetFlagOperand(operand_index);
return iterator().GetFlagOperand(operand_index);
}
uint32_t BaselineCompiler::RegisterCount(int operand_index) {
return accessor().GetRegisterCountOperand(operand_index);
return iterator().GetRegisterCountOperand(operand_index);
}
TaggedIndex BaselineCompiler::IndexAsTagged(int operand_index) {
return TaggedIndex::FromIntptr(Index(operand_index));
......@@ -375,17 +374,17 @@ void BaselineCompiler::SelectBooleanConstant(
void BaselineCompiler::AddPosition() {
bytecode_offset_table_builder_.AddPosition(__ pc_offset(),
accessor().current_offset());
iterator().current_offset());
}
void BaselineCompiler::PreVisitSingleBytecode() {
if (accessor().current_bytecode() == interpreter::Bytecode::kJumpLoop) {
EnsureLabels(accessor().GetJumpTargetOffset());
if (iterator().current_bytecode() == interpreter::Bytecode::kJumpLoop) {
EnsureLabels(iterator().GetJumpTargetOffset());
}
}
void BaselineCompiler::VisitSingleBytecode() {
int offset = accessor().current_offset();
int offset = iterator().current_offset();
if (labels_[offset]) {
// Bind labels for this offset that have already been linked to a
// jump (i.e. forward jumps, excluding jump tables).
......@@ -399,7 +398,7 @@ void BaselineCompiler::VisitSingleBytecode() {
}
// Record positions of exception handlers.
if (handler_offsets_.find(accessor().current_offset()) !=
if (handler_offsets_.find(iterator().current_offset()) !=
handler_offsets_.end()) {
AddPosition();
__ ExceptionHandler();
......@@ -408,7 +407,7 @@ void BaselineCompiler::VisitSingleBytecode() {
if (FLAG_code_comments) {
std::ostringstream str;
str << "[ ";
accessor().PrintTo(str);
iterator().PrintTo(str);
__ RecordComment(str.str().c_str());
}
......@@ -418,7 +417,7 @@ void BaselineCompiler::VisitSingleBytecode() {
TraceBytecode(Runtime::kTraceUnoptimizedBytecodeEntry);
#endif
switch (accessor().current_bytecode()) {
switch (iterator().current_bytecode()) {
#define BYTECODE_CASE(name, ...) \
case interpreter::Bytecode::k##name: \
Visit##name(); \
......@@ -469,7 +468,7 @@ void BaselineCompiler::TraceBytecode(Runtime::FunctionId function_id) {
SaveAccumulatorScope accumulator_scope(&basm_);
CallRuntime(function_id, bytecode_,
Smi::FromInt(BytecodeArray::kHeaderSize - kHeapObjectTag +
accessor().current_offset()),
iterator().current_offset()),
kInterpreterAccumulatorRegister);
__ RecordComment("]");
}
......@@ -501,7 +500,7 @@ void BaselineCompiler::UpdateInterruptBudgetAndJumpToLabel(
}
void BaselineCompiler::UpdateInterruptBudgetAndDoInterpreterJump() {
int weight = accessor().GetRelativeJumpTargetOffset();
int weight = iterator().GetRelativeJumpTargetOffset();
UpdateInterruptBudgetAndJumpToLabel(weight, BuildForwardJumpLabel(), nullptr);
}
......@@ -524,7 +523,7 @@ void BaselineCompiler::UpdateInterruptBudgetAndDoInterpreterJumpIfNotRoot(
}
Label* BaselineCompiler::BuildForwardJumpLabel() {
int target_offset = accessor().GetJumpTargetOffset();
int target_offset = iterator().GetJumpTargetOffset();
ThreadedLabel* threaded_label = zone_.New<ThreadedLabel>();
EnsureLabels(target_offset)->linked.Add(threaded_label);
return &threaded_label->label;
......@@ -592,7 +591,7 @@ void BaselineCompiler::VisitLdaZero() {
}
void BaselineCompiler::VisitLdaSmi() {
Smi constant = Smi::FromInt(accessor().GetImmediateOperand(0));
Smi constant = Smi::FromInt(iterator().GetImmediateOperand(0));
__ Move(kInterpreterAccumulatorRegister, constant);
}
......@@ -691,7 +690,7 @@ void BaselineCompiler::VisitStaContextSlot() {
Register value = scratch_scope.AcquireScratch();
__ Move(value, kInterpreterAccumulatorRegister);
__ StoreTaggedFieldWithWriteBarrier(
context, Context::OffsetOfElementAt(accessor().GetIndexOperand(1)),
context, Context::OffsetOfElementAt(iterator().GetIndexOperand(1)),
value);
}
......@@ -1110,13 +1109,13 @@ void BaselineCompiler::BuildCall(ConvertReceiverMode mode, uint32_t slot,
}
void BaselineCompiler::VisitCallAnyReceiver() {
interpreter::RegisterList args = accessor().GetRegisterListOperand(1);
interpreter::RegisterList args = iterator().GetRegisterListOperand(1);
uint32_t arg_count = args.register_count() - 1; // Remove receiver.
BuildCall(ConvertReceiverMode::kAny, Index(3), arg_count, args);
}
void BaselineCompiler::VisitCallProperty() {
interpreter::RegisterList args = accessor().GetRegisterListOperand(1);
interpreter::RegisterList args = iterator().GetRegisterListOperand(1);
uint32_t arg_count = args.register_count() - 1; // Remove receiver.
BuildCall(ConvertReceiverMode::kNotNullOrUndefined, Index(3), arg_count,
args);
......@@ -1138,7 +1137,7 @@ void BaselineCompiler::VisitCallProperty2() {
}
void BaselineCompiler::VisitCallUndefinedReceiver() {
interpreter::RegisterList args = accessor().GetRegisterListOperand(1);
interpreter::RegisterList args = iterator().GetRegisterListOperand(1);
uint32_t arg_count = args.register_count();
BuildCall(ConvertReceiverMode::kNullOrUndefined, Index(3), arg_count,
RootIndex::kUndefinedValue, args);
......@@ -1160,7 +1159,7 @@ void BaselineCompiler::VisitCallUndefinedReceiver2() {
}
void BaselineCompiler::VisitCallNoFeedback() {
interpreter::RegisterList args = accessor().GetRegisterListOperand(1);
interpreter::RegisterList args = iterator().GetRegisterListOperand(1);
uint32_t arg_count = args.register_count();
CallBuiltin(Builtins::kCall_ReceiverIsAny,
RegisterOperand(0), // kFunction
......@@ -1169,7 +1168,7 @@ void BaselineCompiler::VisitCallNoFeedback() {
}
void BaselineCompiler::VisitCallWithSpread() {
interpreter::RegisterList args = accessor().GetRegisterListOperand(1);
interpreter::RegisterList args = iterator().GetRegisterListOperand(1);
// Do not push the spread argument
interpreter::Register spread_register = args.last_register();
......@@ -1186,24 +1185,24 @@ void BaselineCompiler::VisitCallWithSpread() {
}
void BaselineCompiler::VisitCallRuntime() {
CallRuntime(accessor().GetRuntimeIdOperand(0),
accessor().GetRegisterListOperand(1));
CallRuntime(iterator().GetRuntimeIdOperand(0),
iterator().GetRegisterListOperand(1));
}
void BaselineCompiler::VisitCallRuntimeForPair() {
CallRuntime(accessor().GetRuntimeIdOperand(0),
accessor().GetRegisterListOperand(1));
CallRuntime(iterator().GetRuntimeIdOperand(0),
iterator().GetRegisterListOperand(1));
StoreRegisterPair(3, kReturnRegister0, kReturnRegister1);
}
void BaselineCompiler::VisitCallJSRuntime() {
interpreter::RegisterList args = accessor().GetRegisterListOperand(1);
interpreter::RegisterList args = iterator().GetRegisterListOperand(1);
uint32_t arg_count = args.register_count();
// Load context for LoadNativeContextSlot.
__ LoadContext(kContextRegister);
__ LoadNativeContextSlot(kJavaScriptCallTargetRegister,
accessor().GetNativeContextIndexOperand(0));
iterator().GetNativeContextIndexOperand(0));
CallBuiltin(Builtins::kCall_ReceiverIsNullOrUndefined,
kJavaScriptCallTargetRegister, // kFunction
arg_count, // kActualArgumentsCount
......@@ -1212,8 +1211,8 @@ void BaselineCompiler::VisitCallJSRuntime() {
}
void BaselineCompiler::VisitInvokeIntrinsic() {
Runtime::FunctionId intrinsic_id = accessor().GetIntrinsicIdOperand(0);
interpreter::RegisterList args = accessor().GetRegisterListOperand(1);
Runtime::FunctionId intrinsic_id = iterator().GetIntrinsicIdOperand(0);
interpreter::RegisterList args = iterator().GetRegisterListOperand(1);
switch (intrinsic_id) {
#define CASE(Name, ...) \
case Runtime::kInline##Name: \
......@@ -1402,7 +1401,7 @@ void BaselineCompiler::VisitIntrinsicAsyncGeneratorYield(
}
void BaselineCompiler::VisitConstruct() {
interpreter::RegisterList args = accessor().GetRegisterListOperand(1);
interpreter::RegisterList args = iterator().GetRegisterListOperand(1);
uint32_t arg_count = args.register_count();
CallBuiltin(Builtins::kConstruct_Baseline,
RegisterOperand(0), // kFunction
......@@ -1414,7 +1413,7 @@ void BaselineCompiler::VisitConstruct() {
}
void BaselineCompiler::VisitConstructWithSpread() {
interpreter::RegisterList args = accessor().GetRegisterListOperand(1);
interpreter::RegisterList args = iterator().GetRegisterListOperand(1);
// Do not push the spread argument
interpreter::Register spread_register = args.last_register();
......@@ -1756,15 +1755,15 @@ void BaselineCompiler::VisitJumpLoop() {
Register osr_level = scratch;
__ LoadRegister(osr_level, interpreter::Register::bytecode_array());
__ LoadByteField(osr_level, osr_level, BytecodeArray::kOsrNestingLevelOffset);
int loop_depth = accessor().GetImmediateOperand(1);
int loop_depth = iterator().GetImmediateOperand(1);
__ CompareByte(osr_level, loop_depth);
__ JumpIf(Condition::kUnsignedLessThanEqual, &osr_not_armed);
CallBuiltin(Builtins::kBaselineOnStackReplacement);
__ RecordComment("]");
__ Bind(&osr_not_armed);
Label* label = &labels_[accessor().GetJumpTargetOffset()]->unlinked;
int weight = accessor().GetRelativeJumpTargetOffset();
Label* label = &labels_[iterator().GetJumpTargetOffset()]->unlinked;
int weight = iterator().GetRelativeJumpTargetOffset();
// We can pass in the same label twice since it's a back edge and thus already
// bound.
DCHECK(label->is_bound());
......@@ -1879,7 +1878,7 @@ void BaselineCompiler::VisitJumpIfJSReceiver() {
void BaselineCompiler::VisitSwitchOnSmiNoFeedback() {
BaselineAssembler::ScratchRegisterScope scratch_scope(&basm_);
interpreter::JumpTableTargetOffsets offsets =
accessor().GetJumpTableTargetOffsets();
iterator().GetJumpTableTargetOffsets();
if (offsets.size() == 0) return;
......@@ -1903,7 +1902,7 @@ void BaselineCompiler::VisitForInPrepare() {
StoreRegister(0, kInterpreterAccumulatorRegister);
CallBuiltin(Builtins::kForInPrepare, kInterpreterAccumulatorRegister,
IndexAsTagged(1), FeedbackVector());
interpreter::Register first = accessor().GetRegisterOperand(0);
interpreter::Register first = iterator().GetRegisterOperand(0);
interpreter::Register second(first.index() + 1);
interpreter::Register third(first.index() + 2);
__ StoreRegister(second, kReturnRegister0);
......@@ -1923,7 +1922,7 @@ void BaselineCompiler::VisitForInContinue() {
void BaselineCompiler::VisitForInNext() {
interpreter::Register cache_type, cache_array;
std::tie(cache_type, cache_array) = accessor().GetRegisterPairOperand(2);
std::tie(cache_type, cache_array) = iterator().GetRegisterPairOperand(2);
CallBuiltin(Builtins::kForInNext,
Index(3), // vector slot
RegisterOperand(0), // object
......@@ -1961,7 +1960,7 @@ void BaselineCompiler::VisitReThrow() {
void BaselineCompiler::VisitReturn() {
__ RecordComment("[ Return");
int profiling_weight = accessor().current_offset();
int profiling_weight = iterator().current_offset();
int parameter_count = bytecode_->parameter_count();
// We must pop all arguments from the stack (including the receiver). This
......@@ -2043,7 +2042,7 @@ void BaselineCompiler::VisitSwitchOnGeneratorState() {
__ StoreContext(context);
interpreter::JumpTableTargetOffsets offsets =
accessor().GetJumpTableTargetOffsets();
iterator().GetJumpTableTargetOffsets();
if (0 < offsets.size()) {
DCHECK_EQ(0, (*offsets.begin()).case_value);
......@@ -2064,7 +2063,7 @@ void BaselineCompiler::VisitSwitchOnGeneratorState() {
}
void BaselineCompiler::VisitSuspendGenerator() {
DCHECK_EQ(accessor().GetRegisterOperand(1), interpreter::Register(0));
DCHECK_EQ(iterator().GetRegisterOperand(1), interpreter::Register(0));
int register_count = RegisterCount(2);
uint32_t suspend_id = Uint(3);
......@@ -2103,12 +2102,12 @@ void BaselineCompiler::VisitSuspendGenerator() {
__ StoreTaggedSignedField(
generator_object, JSGeneratorObject::kInputOrDebugPosOffset,
Smi::FromInt(BytecodeArray::kHeaderSize + accessor().current_offset()));
Smi::FromInt(BytecodeArray::kHeaderSize + iterator().current_offset()));
VisitReturn();
}
void BaselineCompiler::VisitResumeGenerator() {
DCHECK_EQ(accessor().GetRegisterOperand(1), interpreter::Register(0));
DCHECK_EQ(iterator().GetRegisterOperand(1), interpreter::Register(0));
int register_count = RegisterCount(2);
BaselineAssembler::ScratchRegisterScope scratch_scope(&basm_);
......
......@@ -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 =
......
// Copyright 2015 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.
#include "src/interpreter/bytecode-array-accessor.h"
#include "src/interpreter/bytecode-decoder.h"
#include "src/interpreter/interpreter-intrinsics.h"
#include "src/objects/code-inl.h"
#include "src/objects/feedback-vector.h"
#include "src/objects/objects-inl.h"
namespace v8 {
namespace internal {
namespace interpreter {
BytecodeArrayAccessor::BytecodeArrayAccessor(
Handle<BytecodeArray> bytecode_array, int initial_offset)
: bytecode_array_(bytecode_array),
start_(reinterpret_cast<uint8_t*>(
bytecode_array_->GetFirstBytecodeAddress())),
end_(start_ + bytecode_array_->length()),
cursor_(start_ + initial_offset),
operand_scale_(OperandScale::kSingle),
prefix_size_(0),
local_heap_(LocalHeap::Current()
? LocalHeap::Current()
: Isolate::Current()->main_thread_local_heap()) {
local_heap_->AddGCEpilogueCallback(UpdatePointersCallback, this);
UpdateOperandScale();
}
BytecodeArrayAccessor::~BytecodeArrayAccessor() {
local_heap_->RemoveGCEpilogueCallback(UpdatePointersCallback, this);
}
void BytecodeArrayAccessor::SetOffset(int offset) {
if (offset < 0) return;
cursor_ = reinterpret_cast<uint8_t*>(
bytecode_array()->GetFirstBytecodeAddress() + offset);
UpdateOperandScale();
}
void BytecodeArrayAccessor::ApplyDebugBreak() {
// Get the raw bytecode from the bytecode array. This may give us a
// scaling prefix, which we can patch with the matching debug-break
// variant.
uint8_t* cursor = cursor_ - prefix_size_;
interpreter::Bytecode bytecode = interpreter::Bytecodes::FromByte(*cursor);
if (interpreter::Bytecodes::IsDebugBreak(bytecode)) return;
interpreter::Bytecode debugbreak =
interpreter::Bytecodes::GetDebugBreak(bytecode);
*cursor = interpreter::Bytecodes::ToByte(debugbreak);
}
int BytecodeArrayAccessor::current_bytecode_size() const {
return prefix_size_ +
Bytecodes::Size(current_bytecode(), current_operand_scale());
}
uint32_t BytecodeArrayAccessor::GetUnsignedOperand(
int operand_index, OperandType operand_type) const {
DCHECK_GE(operand_index, 0);
DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode()));
DCHECK_EQ(operand_type,
Bytecodes::GetOperandType(current_bytecode(), operand_index));
DCHECK(Bytecodes::IsUnsignedOperandType(operand_type));
Address operand_start =
reinterpret_cast<Address>(cursor_) +
Bytecodes::GetOperandOffset(current_bytecode(), operand_index,
current_operand_scale());
return BytecodeDecoder::DecodeUnsignedOperand(operand_start, operand_type,
current_operand_scale());
}
int32_t BytecodeArrayAccessor::GetSignedOperand(
int operand_index, OperandType operand_type) const {
DCHECK_GE(operand_index, 0);
DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode()));
DCHECK_EQ(operand_type,
Bytecodes::GetOperandType(current_bytecode(), operand_index));
DCHECK(!Bytecodes::IsUnsignedOperandType(operand_type));
Address operand_start =
reinterpret_cast<Address>(cursor_) +
Bytecodes::GetOperandOffset(current_bytecode(), operand_index,
current_operand_scale());
return BytecodeDecoder::DecodeSignedOperand(operand_start, operand_type,
current_operand_scale());
}
uint32_t BytecodeArrayAccessor::GetFlagOperand(int operand_index) const {
DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index),
OperandType::kFlag8);
return GetUnsignedOperand(operand_index, OperandType::kFlag8);
}
uint32_t BytecodeArrayAccessor::GetUnsignedImmediateOperand(
int operand_index) const {
DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index),
OperandType::kUImm);
return GetUnsignedOperand(operand_index, OperandType::kUImm);
}
int32_t BytecodeArrayAccessor::GetImmediateOperand(int operand_index) const {
DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index),
OperandType::kImm);
return GetSignedOperand(operand_index, OperandType::kImm);
}
uint32_t BytecodeArrayAccessor::GetRegisterCountOperand(
int operand_index) const {
DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index),
OperandType::kRegCount);
return GetUnsignedOperand(operand_index, OperandType::kRegCount);
}
uint32_t BytecodeArrayAccessor::GetIndexOperand(int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
DCHECK_EQ(operand_type, OperandType::kIdx);
return GetUnsignedOperand(operand_index, operand_type);
}
FeedbackSlot BytecodeArrayAccessor::GetSlotOperand(int operand_index) const {
int index = GetIndexOperand(operand_index);
return FeedbackVector::ToSlot(index);
}
Register BytecodeArrayAccessor::GetReceiver() const {
return Register::FromParameterIndex(0, bytecode_array()->parameter_count());
}
Register BytecodeArrayAccessor::GetParameter(int parameter_index) const {
DCHECK_GE(parameter_index, 0);
// The parameter indices are shifted by 1 (receiver is the
// first entry).
return Register::FromParameterIndex(parameter_index + 1,
bytecode_array()->parameter_count());
}
Register BytecodeArrayAccessor::GetRegisterOperand(int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
Address operand_start =
reinterpret_cast<Address>(cursor_) +
Bytecodes::GetOperandOffset(current_bytecode(), operand_index,
current_operand_scale());
return BytecodeDecoder::DecodeRegisterOperand(operand_start, operand_type,
current_operand_scale());
}
std::pair<Register, Register> BytecodeArrayAccessor::GetRegisterPairOperand(
int operand_index) const {
Register first = GetRegisterOperand(operand_index);
Register second(first.index() + 1);
return std::make_pair(first, second);
}
RegisterList BytecodeArrayAccessor::GetRegisterListOperand(
int operand_index) const {
Register first = GetRegisterOperand(operand_index);
uint32_t count = GetRegisterCountOperand(operand_index + 1);
return RegisterList(first.index(), count);
}
int BytecodeArrayAccessor::GetRegisterOperandRange(int operand_index) const {
DCHECK_LE(operand_index, Bytecodes::NumberOfOperands(current_bytecode()));
const OperandType* operand_types =
Bytecodes::GetOperandTypes(current_bytecode());
OperandType operand_type = operand_types[operand_index];
DCHECK(Bytecodes::IsRegisterOperandType(operand_type));
if (operand_type == OperandType::kRegList ||
operand_type == OperandType::kRegOutList) {
return GetRegisterCountOperand(operand_index + 1);
} else {
return Bytecodes::GetNumberOfRegistersRepresentedBy(operand_type);
}
}
Runtime::FunctionId BytecodeArrayAccessor::GetRuntimeIdOperand(
int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
DCHECK_EQ(operand_type, OperandType::kRuntimeId);
uint32_t raw_id = GetUnsignedOperand(operand_index, operand_type);
return static_cast<Runtime::FunctionId>(raw_id);
}
uint32_t BytecodeArrayAccessor::GetNativeContextIndexOperand(
int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
DCHECK_EQ(operand_type, OperandType::kNativeContextIndex);
return GetUnsignedOperand(operand_index, operand_type);
}
Runtime::FunctionId BytecodeArrayAccessor::GetIntrinsicIdOperand(
int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
DCHECK_EQ(operand_type, OperandType::kIntrinsicId);
uint32_t raw_id = GetUnsignedOperand(operand_index, operand_type);
return IntrinsicsHelper::ToRuntimeId(
static_cast<IntrinsicsHelper::IntrinsicId>(raw_id));
}
template <typename LocalIsolate>
Handle<Object> BytecodeArrayAccessor::GetConstantAtIndex(
int index, LocalIsolate* isolate) const {
return handle(bytecode_array()->constant_pool().get(index), isolate);
}
bool BytecodeArrayAccessor::IsConstantAtIndexSmi(int index) const {
return bytecode_array()->constant_pool().get(index).IsSmi();
}
Smi BytecodeArrayAccessor::GetConstantAtIndexAsSmi(int index) const {
return Smi::cast(bytecode_array()->constant_pool().get(index));
}
template <typename LocalIsolate>
Handle<Object> BytecodeArrayAccessor::GetConstantForIndexOperand(
int operand_index, LocalIsolate* isolate) const {
return GetConstantAtIndex(GetIndexOperand(operand_index), isolate);
}
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<Object> BytecodeArrayAccessor::GetConstantForIndexOperand(
int operand_index, Isolate* isolate) const;
template Handle<Object> BytecodeArrayAccessor::GetConstantForIndexOperand(
int operand_index, LocalIsolate* isolate) const;
int BytecodeArrayAccessor::GetRelativeJumpTargetOffset() const {
Bytecode bytecode = current_bytecode();
if (interpreter::Bytecodes::IsJumpImmediate(bytecode)) {
int relative_offset = GetUnsignedImmediateOperand(0);
if (bytecode == Bytecode::kJumpLoop) {
relative_offset = -relative_offset;
}
return relative_offset;
} else if (interpreter::Bytecodes::IsJumpConstant(bytecode)) {
Smi smi = GetConstantAtIndexAsSmi(GetIndexOperand(0));
return smi.value();
} else {
UNREACHABLE();
}
}
int BytecodeArrayAccessor::GetJumpTargetOffset() const {
return GetAbsoluteOffset(GetRelativeJumpTargetOffset());
}
JumpTableTargetOffsets BytecodeArrayAccessor::GetJumpTableTargetOffsets()
const {
uint32_t table_start, table_size;
int32_t case_value_base;
if (current_bytecode() == Bytecode::kSwitchOnGeneratorState) {
table_start = GetIndexOperand(1);
table_size = GetUnsignedImmediateOperand(2);
case_value_base = 0;
} else {
DCHECK_EQ(current_bytecode(), Bytecode::kSwitchOnSmiNoFeedback);
table_start = GetIndexOperand(0);
table_size = GetUnsignedImmediateOperand(1);
case_value_base = GetImmediateOperand(2);
}
return JumpTableTargetOffsets(this, table_start, table_size, case_value_base);
}
int BytecodeArrayAccessor::GetAbsoluteOffset(int relative_offset) const {
return current_offset() + relative_offset + prefix_size_;
}
std::ostream& BytecodeArrayAccessor::PrintTo(std::ostream& os) const {
return BytecodeDecoder::Decode(os, cursor_ - prefix_size_,
bytecode_array()->parameter_count());
}
void BytecodeArrayAccessor::UpdatePointers() {
DisallowGarbageCollection no_gc;
uint8_t* start =
reinterpret_cast<uint8_t*>(bytecode_array_->GetFirstBytecodeAddress());
if (start != start_) {
start_ = start;
uint8_t* end = start + bytecode_array_->length();
size_t distance_to_end = end_ - cursor_;
cursor_ = end - distance_to_end;
end_ = end;
}
}
JumpTableTargetOffsets::JumpTableTargetOffsets(
const BytecodeArrayAccessor* accessor, int table_start, int table_size,
int case_value_base)
: accessor_(accessor),
table_start_(table_start),
table_size_(table_size),
case_value_base_(case_value_base) {}
JumpTableTargetOffsets::iterator JumpTableTargetOffsets::begin() const {
return iterator(case_value_base_, table_start_, table_start_ + table_size_,
accessor_);
}
JumpTableTargetOffsets::iterator JumpTableTargetOffsets::end() const {
return iterator(case_value_base_ + table_size_, table_start_ + table_size_,
table_start_ + table_size_, accessor_);
}
int JumpTableTargetOffsets::size() const {
int ret = 0;
// TODO(leszeks): Is there a more efficient way of doing this than iterating?
for (const auto& entry : *this) {
USE(entry);
ret++;
}
return ret;
}
JumpTableTargetOffsets::iterator::iterator(
int case_value, int table_offset, int table_end,
const BytecodeArrayAccessor* accessor)
: accessor_(accessor),
current_(Smi::zero()),
index_(case_value),
table_offset_(table_offset),
table_end_(table_end) {
UpdateAndAdvanceToValid();
}
JumpTableTargetOffset JumpTableTargetOffsets::iterator::operator*() {
DCHECK_LT(table_offset_, table_end_);
return {index_, accessor_->GetAbsoluteOffset(Smi::ToInt(current_))};
}
JumpTableTargetOffsets::iterator& JumpTableTargetOffsets::iterator::
operator++() {
DCHECK_LT(table_offset_, table_end_);
++table_offset_;
++index_;
UpdateAndAdvanceToValid();
return *this;
}
bool JumpTableTargetOffsets::iterator::operator!=(
const JumpTableTargetOffsets::iterator& other) {
DCHECK_EQ(accessor_, other.accessor_);
DCHECK_EQ(table_end_, other.table_end_);
DCHECK_EQ(index_ - other.index_, table_offset_ - other.table_offset_);
return index_ != other.index_;
}
void JumpTableTargetOffsets::iterator::UpdateAndAdvanceToValid() {
while (table_offset_ < table_end_ &&
!accessor_->IsConstantAtIndexSmi(table_offset_)) {
++table_offset_;
++index_;
}
// Make sure we haven't reached the end of the table with a hole in current.
if (table_offset_ < table_end_) {
DCHECK(accessor_->IsConstantAtIndexSmi(table_offset_));
current_ = accessor_->GetConstantAtIndexAsSmi(table_offset_);
}
}
} // namespace interpreter
} // namespace internal
} // namespace v8
// 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_
......@@ -3,7 +3,11 @@
// found in the LICENSE file.
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-decoder.h"
#include "src/interpreter/interpreter-intrinsics.h"
#include "src/objects/code-inl.h"
#include "src/objects/feedback-vector.h"
#include "src/objects/objects-inl.h"
namespace v8 {
......@@ -11,8 +15,352 @@ namespace internal {
namespace interpreter {
BytecodeArrayIterator::BytecodeArrayIterator(
Handle<BytecodeArray> bytecode_array)
: BytecodeArrayAccessor(bytecode_array, 0) {}
Handle<BytecodeArray> bytecode_array, int initial_offset)
: bytecode_array_(bytecode_array),
start_(reinterpret_cast<uint8_t*>(
bytecode_array_->GetFirstBytecodeAddress())),
end_(start_ + bytecode_array_->length()),
cursor_(start_ + initial_offset),
operand_scale_(OperandScale::kSingle),
prefix_size_(0),
local_heap_(LocalHeap::Current()
? LocalHeap::Current()
: Isolate::Current()->main_thread_local_heap()) {
local_heap_->AddGCEpilogueCallback(UpdatePointersCallback, this);
UpdateOperandScale();
}
BytecodeArrayIterator::~BytecodeArrayIterator() {
local_heap_->RemoveGCEpilogueCallback(UpdatePointersCallback, this);
}
void BytecodeArrayIterator::SetOffset(int offset) {
if (offset < 0) return;
cursor_ = reinterpret_cast<uint8_t*>(
bytecode_array()->GetFirstBytecodeAddress() + offset);
UpdateOperandScale();
}
void BytecodeArrayIterator::ApplyDebugBreak() {
// Get the raw bytecode from the bytecode array. This may give us a
// scaling prefix, which we can patch with the matching debug-break
// variant.
uint8_t* cursor = cursor_ - prefix_size_;
interpreter::Bytecode bytecode = interpreter::Bytecodes::FromByte(*cursor);
if (interpreter::Bytecodes::IsDebugBreak(bytecode)) return;
interpreter::Bytecode debugbreak =
interpreter::Bytecodes::GetDebugBreak(bytecode);
*cursor = interpreter::Bytecodes::ToByte(debugbreak);
}
int BytecodeArrayIterator::current_bytecode_size() const {
return prefix_size_ +
Bytecodes::Size(current_bytecode(), current_operand_scale());
}
uint32_t BytecodeArrayIterator::GetUnsignedOperand(
int operand_index, OperandType operand_type) const {
DCHECK_GE(operand_index, 0);
DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode()));
DCHECK_EQ(operand_type,
Bytecodes::GetOperandType(current_bytecode(), operand_index));
DCHECK(Bytecodes::IsUnsignedOperandType(operand_type));
Address operand_start =
reinterpret_cast<Address>(cursor_) +
Bytecodes::GetOperandOffset(current_bytecode(), operand_index,
current_operand_scale());
return BytecodeDecoder::DecodeUnsignedOperand(operand_start, operand_type,
current_operand_scale());
}
int32_t BytecodeArrayIterator::GetSignedOperand(
int operand_index, OperandType operand_type) const {
DCHECK_GE(operand_index, 0);
DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode()));
DCHECK_EQ(operand_type,
Bytecodes::GetOperandType(current_bytecode(), operand_index));
DCHECK(!Bytecodes::IsUnsignedOperandType(operand_type));
Address operand_start =
reinterpret_cast<Address>(cursor_) +
Bytecodes::GetOperandOffset(current_bytecode(), operand_index,
current_operand_scale());
return BytecodeDecoder::DecodeSignedOperand(operand_start, operand_type,
current_operand_scale());
}
uint32_t BytecodeArrayIterator::GetFlagOperand(int operand_index) const {
DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index),
OperandType::kFlag8);
return GetUnsignedOperand(operand_index, OperandType::kFlag8);
}
uint32_t BytecodeArrayIterator::GetUnsignedImmediateOperand(
int operand_index) const {
DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index),
OperandType::kUImm);
return GetUnsignedOperand(operand_index, OperandType::kUImm);
}
int32_t BytecodeArrayIterator::GetImmediateOperand(int operand_index) const {
DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index),
OperandType::kImm);
return GetSignedOperand(operand_index, OperandType::kImm);
}
uint32_t BytecodeArrayIterator::GetRegisterCountOperand(
int operand_index) const {
DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index),
OperandType::kRegCount);
return GetUnsignedOperand(operand_index, OperandType::kRegCount);
}
uint32_t BytecodeArrayIterator::GetIndexOperand(int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
DCHECK_EQ(operand_type, OperandType::kIdx);
return GetUnsignedOperand(operand_index, operand_type);
}
FeedbackSlot BytecodeArrayIterator::GetSlotOperand(int operand_index) const {
int index = GetIndexOperand(operand_index);
return FeedbackVector::ToSlot(index);
}
Register BytecodeArrayIterator::GetReceiver() const {
return Register::FromParameterIndex(0, bytecode_array()->parameter_count());
}
Register BytecodeArrayIterator::GetParameter(int parameter_index) const {
DCHECK_GE(parameter_index, 0);
// The parameter indices are shifted by 1 (receiver is the
// first entry).
return Register::FromParameterIndex(parameter_index + 1,
bytecode_array()->parameter_count());
}
Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
Address operand_start =
reinterpret_cast<Address>(cursor_) +
Bytecodes::GetOperandOffset(current_bytecode(), operand_index,
current_operand_scale());
return BytecodeDecoder::DecodeRegisterOperand(operand_start, operand_type,
current_operand_scale());
}
std::pair<Register, Register> BytecodeArrayIterator::GetRegisterPairOperand(
int operand_index) const {
Register first = GetRegisterOperand(operand_index);
Register second(first.index() + 1);
return std::make_pair(first, second);
}
RegisterList BytecodeArrayIterator::GetRegisterListOperand(
int operand_index) const {
Register first = GetRegisterOperand(operand_index);
uint32_t count = GetRegisterCountOperand(operand_index + 1);
return RegisterList(first.index(), count);
}
int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const {
DCHECK_LE(operand_index, Bytecodes::NumberOfOperands(current_bytecode()));
const OperandType* operand_types =
Bytecodes::GetOperandTypes(current_bytecode());
OperandType operand_type = operand_types[operand_index];
DCHECK(Bytecodes::IsRegisterOperandType(operand_type));
if (operand_type == OperandType::kRegList ||
operand_type == OperandType::kRegOutList) {
return GetRegisterCountOperand(operand_index + 1);
} else {
return Bytecodes::GetNumberOfRegistersRepresentedBy(operand_type);
}
}
Runtime::FunctionId BytecodeArrayIterator::GetRuntimeIdOperand(
int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
DCHECK_EQ(operand_type, OperandType::kRuntimeId);
uint32_t raw_id = GetUnsignedOperand(operand_index, operand_type);
return static_cast<Runtime::FunctionId>(raw_id);
}
uint32_t BytecodeArrayIterator::GetNativeContextIndexOperand(
int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
DCHECK_EQ(operand_type, OperandType::kNativeContextIndex);
return GetUnsignedOperand(operand_index, operand_type);
}
Runtime::FunctionId BytecodeArrayIterator::GetIntrinsicIdOperand(
int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
DCHECK_EQ(operand_type, OperandType::kIntrinsicId);
uint32_t raw_id = GetUnsignedOperand(operand_index, operand_type);
return IntrinsicsHelper::ToRuntimeId(
static_cast<IntrinsicsHelper::IntrinsicId>(raw_id));
}
template <typename LocalIsolate>
Handle<Object> BytecodeArrayIterator::GetConstantAtIndex(
int index, LocalIsolate* isolate) const {
return handle(bytecode_array()->constant_pool().get(index), isolate);
}
bool BytecodeArrayIterator::IsConstantAtIndexSmi(int index) const {
return bytecode_array()->constant_pool().get(index).IsSmi();
}
Smi BytecodeArrayIterator::GetConstantAtIndexAsSmi(int index) const {
return Smi::cast(bytecode_array()->constant_pool().get(index));
}
template <typename LocalIsolate>
Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand(
int operand_index, LocalIsolate* isolate) const {
return GetConstantAtIndex(GetIndexOperand(operand_index), isolate);
}
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand(
int operand_index, Isolate* isolate) const;
template Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand(
int operand_index, LocalIsolate* isolate) const;
int BytecodeArrayIterator::GetRelativeJumpTargetOffset() const {
Bytecode bytecode = current_bytecode();
if (interpreter::Bytecodes::IsJumpImmediate(bytecode)) {
int relative_offset = GetUnsignedImmediateOperand(0);
if (bytecode == Bytecode::kJumpLoop) {
relative_offset = -relative_offset;
}
return relative_offset;
} else if (interpreter::Bytecodes::IsJumpConstant(bytecode)) {
Smi smi = GetConstantAtIndexAsSmi(GetIndexOperand(0));
return smi.value();
} else {
UNREACHABLE();
}
}
int BytecodeArrayIterator::GetJumpTargetOffset() const {
return GetAbsoluteOffset(GetRelativeJumpTargetOffset());
}
JumpTableTargetOffsets BytecodeArrayIterator::GetJumpTableTargetOffsets()
const {
uint32_t table_start, table_size;
int32_t case_value_base;
if (current_bytecode() == Bytecode::kSwitchOnGeneratorState) {
table_start = GetIndexOperand(1);
table_size = GetUnsignedImmediateOperand(2);
case_value_base = 0;
} else {
DCHECK_EQ(current_bytecode(), Bytecode::kSwitchOnSmiNoFeedback);
table_start = GetIndexOperand(0);
table_size = GetUnsignedImmediateOperand(1);
case_value_base = GetImmediateOperand(2);
}
return JumpTableTargetOffsets(this, table_start, table_size, case_value_base);
}
int BytecodeArrayIterator::GetAbsoluteOffset(int relative_offset) const {
return current_offset() + relative_offset + prefix_size_;
}
std::ostream& BytecodeArrayIterator::PrintTo(std::ostream& os) const {
return BytecodeDecoder::Decode(os, cursor_ - prefix_size_,
bytecode_array()->parameter_count());
}
void BytecodeArrayIterator::UpdatePointers() {
DisallowGarbageCollection no_gc;
uint8_t* start =
reinterpret_cast<uint8_t*>(bytecode_array_->GetFirstBytecodeAddress());
if (start != start_) {
start_ = start;
uint8_t* end = start + bytecode_array_->length();
size_t distance_to_end = end_ - cursor_;
cursor_ = end - distance_to_end;
end_ = end;
}
}
JumpTableTargetOffsets::JumpTableTargetOffsets(
const BytecodeArrayIterator* iterator, int table_start, int table_size,
int case_value_base)
: iterator_(iterator),
table_start_(table_start),
table_size_(table_size),
case_value_base_(case_value_base) {}
JumpTableTargetOffsets::iterator JumpTableTargetOffsets::begin() const {
return iterator(case_value_base_, table_start_, table_start_ + table_size_,
iterator_);
}
JumpTableTargetOffsets::iterator JumpTableTargetOffsets::end() const {
return iterator(case_value_base_ + table_size_, table_start_ + table_size_,
table_start_ + table_size_, iterator_);
}
int JumpTableTargetOffsets::size() const {
int ret = 0;
// TODO(leszeks): Is there a more efficient way of doing this than iterating?
for (const auto& entry : *this) {
USE(entry);
ret++;
}
return ret;
}
JumpTableTargetOffsets::iterator::iterator(
int case_value, int table_offset, int table_end,
const BytecodeArrayIterator* iterator)
: iterator_(iterator),
current_(Smi::zero()),
index_(case_value),
table_offset_(table_offset),
table_end_(table_end) {
UpdateAndAdvanceToValid();
}
JumpTableTargetOffset JumpTableTargetOffsets::iterator::operator*() {
DCHECK_LT(table_offset_, table_end_);
return {index_, iterator_->GetAbsoluteOffset(Smi::ToInt(current_))};
}
JumpTableTargetOffsets::iterator&
JumpTableTargetOffsets::iterator::operator++() {
DCHECK_LT(table_offset_, table_end_);
++table_offset_;
++index_;
UpdateAndAdvanceToValid();
return *this;
}
bool JumpTableTargetOffsets::iterator::operator!=(
const JumpTableTargetOffsets::iterator& other) {
DCHECK_EQ(iterator_, other.iterator_);
DCHECK_EQ(table_end_, other.table_end_);
DCHECK_EQ(index_ - other.index_, table_offset_ - other.table_offset_);
return index_ != other.index_;
}
void JumpTableTargetOffsets::iterator::UpdateAndAdvanceToValid() {
while (table_offset_ < table_end_ &&
!iterator_->IsConstantAtIndexSmi(table_offset_)) {
++table_offset_;
++index_;
}
// Make sure we haven't reached the end of the table with a hole in current.
if (table_offset_ < table_end_) {
DCHECK(iterator_->IsConstantAtIndexSmi(table_offset_));
current_ = iterator_->GetConstantAtIndexAsSmi(table_offset_);
}
}
} // namespace interpreter
} // namespace internal
......
......@@ -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