#include "src/compiler/bytecode-analysis.h"
#include <utility>
#include "src/compiler/bytecode-liveness-map.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-array-random-iterator.h"
#include "src/interpreter/bytecodes.h"
#include "src/objects/objects-inl.h"
#include "src/utils/ostreams.h"
namespace v8 {
namespace internal {
namespace compiler {
Bytecode;
BytecodeOperands;
Bytecodes;
ImplicitRegisterUse;
OperandType;
Register;
BytecodeLoopAssignments::BytecodeLoopAssignments(int parameter_count,
int register_count, Zone* zone)
: … { … }
void BytecodeLoopAssignments::Add(interpreter::Register r) { … }
void BytecodeLoopAssignments::AddList(interpreter::Register r, uint32_t count) { … }
void BytecodeLoopAssignments::Union(const BytecodeLoopAssignments& other) { … }
bool BytecodeLoopAssignments::ContainsParameter(int index) const { … }
bool BytecodeLoopAssignments::ContainsLocal(int index) const { … }
ResumeJumpTarget::ResumeJumpTarget(int suspend_id, int target_offset,
int final_target_offset)
: … { … }
ResumeJumpTarget ResumeJumpTarget::Leaf(int suspend_id, int target_offset) { … }
ResumeJumpTarget ResumeJumpTarget::AtLoopHeader(int loop_header_offset,
const ResumeJumpTarget& next) { … }
namespace {
template <Bytecode bytecode, OperandType operand_type, size_t i>
void UpdateInLivenessForOutOperand(
BytecodeLivenessState* in_liveness,
const interpreter::BytecodeArrayIterator& iterator) { … }
template <Bytecode bytecode, OperandType operand_type, size_t i>
void UpdateInLivenessForInOperand(
BytecodeLivenessState* in_liveness,
const interpreter::BytecodeArrayIterator& iterator) { … }
template <Bytecode bytecode, ImplicitRegisterUse implicit_register_use,
OperandType... operand_types, size_t... operand_index>
void UpdateInLiveness(BytecodeLivenessState* in_liveness,
const interpreter::BytecodeArrayIterator& iterator,
std::index_sequence<operand_index...>) { … }
template <Bytecode bytecode, ImplicitRegisterUse implicit_register_use,
OperandType... operand_types>
void UpdateInLiveness(BytecodeLivenessState* in_liveness,
const interpreter::BytecodeArrayIterator& iterator) { … }
#ifdef DEBUG
void UpdateInLiveness(Bytecode bytecode, BytecodeLivenessState* in_liveness,
const interpreter::BytecodeArrayIterator& iterator) { … }
#endif
template <bool IsFirstUpdate = false>
void EnsureOutLivenessIsNotAlias(
BytecodeLiveness& liveness,
BytecodeLivenessState* next_bytecode_in_liveness, Zone* zone) { … }
template <bool IsFirstUpdate, Bytecode bytecode>
void UpdateOutLiveness(BytecodeLiveness& liveness,
BytecodeLivenessState* next_bytecode_in_liveness,
const interpreter::BytecodeArrayIterator& iterator,
DirectHandle<BytecodeArray> bytecode_array,
const BytecodeLivenessMap& liveness_map, Zone* zone) { … }
template <bool IsFirstUpdate = false>
void UpdateOutLiveness(Bytecode bytecode, BytecodeLiveness& liveness,
BytecodeLivenessState* next_bytecode_in_liveness,
const interpreter::BytecodeArrayIterator& iterator,
Handle<BytecodeArray> bytecode_array,
const BytecodeLivenessMap& liveness_map, Zone* zone) { … }
template <bool IsFirstUpdate, Bytecode bytecode,
ImplicitRegisterUse implicit_register_use,
OperandType... operand_types>
void UpdateLiveness(BytecodeLiveness& liveness,
BytecodeLivenessState** next_bytecode_in_liveness,
const interpreter::BytecodeArrayIterator& iterator,
Handle<BytecodeArray> bytecode_array,
const BytecodeLivenessMap& liveness_map, Zone* zone) { … }
template <bool IsFirstUpdate = false>
void UpdateLiveness(Bytecode bytecode, BytecodeLiveness& liveness,
BytecodeLivenessState** next_bytecode_in_liveness,
const interpreter::BytecodeArrayIterator& iterator,
Handle<BytecodeArray> bytecode_array,
const BytecodeLivenessMap& liveness_map, Zone* zone) { … }
void UpdateAssignments(Bytecode bytecode, BytecodeLoopAssignments* assignments,
const interpreter::BytecodeArrayIterator& iterator) { … }
}
class BytecodeAnalysis::BytecodeAnalysisImpl { … };
template <>
inline void BytecodeAnalysis::BytecodeAnalysisImpl::AnalyzeBCInLoop<
Bytecode::kSuspendGenerator>(int current_offset,
LoopInfo* current_loop_info) { … }
template <>
inline void BytecodeAnalysis::BytecodeAnalysisImpl::AnalyzeBCInLoop<
Bytecode::kResumeGenerator>(int current_offset,
LoopInfo* current_loop_info) { … }
void BytecodeAnalysis::BytecodeAnalysisImpl::Analyze() { … }
bool BytecodeAnalysis::IsLoopHeader(int offset) const { … }
int BytecodeAnalysis::GetLoopOffsetFor(int offset) const { … }
int BytecodeAnalysis::GetLoopEndOffsetForInnermost(int header_offset) const { … }
const LoopInfo& BytecodeAnalysis::GetLoopInfoFor(int header_offset) const { … }
const LoopInfo* BytecodeAnalysis::TryGetLoopInfoFor(int header_offset) const { … }
const BytecodeLivenessState* BytecodeAnalysis::GetInLivenessFor(
int offset) const { … }
const BytecodeLivenessState* BytecodeAnalysis::GetOutLivenessFor(
int offset) const { … }
std::ostream& BytecodeAnalysis::BytecodeAnalysisImpl::PrintLivenessTo(
std::ostream& os) const { … }
#if DEBUG
bool BytecodeAnalysis::BytecodeAnalysisImpl::ResumeJumpTargetsAreValid() { … }
bool BytecodeAnalysis::BytecodeAnalysisImpl::
ResumeJumpTargetLeavesResolveSuspendIds(
int parent_offset,
const ZoneVector<ResumeJumpTarget>& resume_jump_targets,
std::map<int, int>* unresolved_suspend_ids) { … }
bool BytecodeAnalysis::BytecodeAnalysisImpl::LivenessIsValid() { … }
#endif
BytecodeAnalysis::BytecodeAnalysis(Handle<BytecodeArray> bytecode_array,
Zone* zone, BytecodeOffset osr_bailout_id,
bool analyze_liveness)
: … { … }
}
}
}