Commit 1bd2d7d1 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Rename CodeGenerator's "code" to "instructions"

This avoids confusion with the code that is being generated.

R=sigurds@chromium.org

Change-Id: Icb5bd417ca8502553af201654cca1419b9eac87d
Reviewed-on: https://chromium-review.googlesource.com/c/1462001
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59522}
parent 3abc01f2
......@@ -144,9 +144,9 @@ class InstructionOperandConverter {
Constant ToConstant(InstructionOperand* op) {
if (op->IsImmediate()) {
return gen_->code()->GetImmediate(ImmediateOperand::cast(op));
return gen_->instructions()->GetImmediate(ImmediateOperand::cast(op));
}
return gen_->code()->GetConstant(
return gen_->instructions()->GetConstant(
ConstantOperand::cast(op)->virtual_register());
}
......
......@@ -43,19 +43,19 @@ class CodeGenerator::JumpTable final : public ZoneObject {
CodeGenerator::CodeGenerator(
Zone* codegen_zone, Frame* frame, Linkage* linkage,
InstructionSequence* code, OptimizedCompilationInfo* info, Isolate* isolate,
base::Optional<OsrHelper> osr_helper, int start_source_position,
JumpOptimizationInfo* jump_opt, PoisoningMitigationLevel poisoning_level,
const AssemblerOptions& options, int32_t builtin_index,
std::unique_ptr<AssemblerBuffer> buffer)
InstructionSequence* instructions, OptimizedCompilationInfo* info,
Isolate* isolate, base::Optional<OsrHelper> osr_helper,
int start_source_position, JumpOptimizationInfo* jump_opt,
PoisoningMitigationLevel poisoning_level, const AssemblerOptions& options,
int32_t builtin_index, std::unique_ptr<AssemblerBuffer> buffer)
: zone_(codegen_zone),
isolate_(isolate),
frame_access_state_(nullptr),
linkage_(linkage),
code_(code),
instructions_(instructions),
unwinding_info_writer_(zone()),
info_(info),
labels_(zone()->NewArray<Label>(code->InstructionBlockCount())),
labels_(zone()->NewArray<Label>(instructions->InstructionBlockCount())),
current_block_(RpoNumber::Invalid()),
start_source_position_(start_source_position),
current_source_position_(SourcePosition::Unknown()),
......@@ -80,7 +80,7 @@ CodeGenerator::CodeGenerator(
poisoning_level_(poisoning_level),
block_starts_(zone()),
instr_starts_(zone()) {
for (int i = 0; i < code->InstructionBlockCount(); ++i) {
for (int i = 0; i < instructions->InstructionBlockCount(); ++i) {
new (&labels_[i]) Label;
}
CreateFrameAccessState(frame);
......@@ -186,15 +186,15 @@ void CodeGenerator::AssembleCode() {
}
unwinding_info_writer_.SetNumberOfInstructionBlocks(
code()->InstructionBlockCount());
instructions()->InstructionBlockCount());
if (info->trace_turbo_json_enabled()) {
block_starts_.assign(code()->instruction_blocks().size(), -1);
instr_starts_.assign(code()->instructions().size(), -1);
block_starts_.assign(instructions()->instruction_blocks().size(), -1);
instr_starts_.assign(instructions()->instructions().size(), -1);
}
// Assemble instructions in assembly order.
for (const InstructionBlock* block : code()->ao_blocks()) {
for (const InstructionBlock* block : instructions()->ao_blocks()) {
// Align loop headers on vendor recommended boundaries.
if (block->ShouldAlign() && !tasm()->jump_optimization_info()) {
tasm()->CodeTargetAlign();
......@@ -248,7 +248,7 @@ void CodeGenerator::AssembleCode() {
}
if (result_ != kSuccess) return;
unwinding_info_writer_.EndInstructionBlock(block);
}
}
// Assemble all out-of-line code.
if (ools_) {
......@@ -324,9 +324,9 @@ void CodeGenerator::TryInsertBranchPoisoning(const InstructionBlock* block) {
// instruction. If yes, then perform the masking based on the flags.
if (block->PredecessorCount() != 1) return;
RpoNumber pred_rpo = (block->predecessors())[0];
const InstructionBlock* pred = code()->InstructionBlockAt(pred_rpo);
const InstructionBlock* pred = instructions()->InstructionBlockAt(pred_rpo);
if (pred->code_start() == pred->code_end()) return;
Instruction* instr = code()->InstructionAt(pred->code_end() - 1);
Instruction* instr = instructions()->InstructionAt(pred->code_end() - 1);
FlagsMode mode = FlagsModeField::decode(instr->opcode());
switch (mode) {
case kFlags_branch_and_poison: {
......@@ -422,10 +422,10 @@ MaybeHandle<Code> CodeGenerator::FinalizeCode() {
}
bool CodeGenerator::IsNextInAssemblyOrder(RpoNumber block) const {
return code()
return instructions()
->InstructionBlockAt(current_block_)
->ao_number()
.IsNext(code()->InstructionBlockAt(block)->ao_number());
.IsNext(instructions()->InstructionBlockAt(block)->ao_number());
}
void CodeGenerator::RecordSafepoint(ReferenceMap* references,
......@@ -469,7 +469,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleBlock(
if (info()->trace_turbo_json_enabled()) {
instr_starts_[i] = tasm()->pc_offset();
}
Instruction* instr = code()->InstructionAt(i);
Instruction* instr = instructions()->InstructionAt(i);
CodeGenResult result = AssembleInstruction(instr, block);
if (result != kSuccess) return result;
}
......@@ -637,7 +637,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleInstruction(
if (adjust_stack) AssembleTailCallAfterGap(instr, first_unused_stack_slot);
DCHECK_IMPLIES(
block->must_deconstruct_frame(),
instr != code()->InstructionAt(block->last_instruction_index()) ||
instr != instructions()->InstructionAt(block->last_instruction_index()) ||
instr->IsRet() || instr->IsJump());
if (instr->IsJump() && block->must_deconstruct_frame()) {
AssembleDeconstructFrame();
......@@ -709,7 +709,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleInstruction(
void CodeGenerator::AssembleSourcePosition(Instruction* instr) {
SourcePosition source_position = SourcePosition::Unknown();
if (instr->IsNop() && instr->AreMovesRedundant()) return;
if (!code()->GetSourcePosition(instr, &source_position)) return;
if (!instructions()->GetSourcePosition(instr, &source_position)) return;
AssembleSourcePosition(source_position);
}
......@@ -899,7 +899,7 @@ DeoptimizationEntry const& CodeGenerator::GetDeoptimizationEntry(
Instruction* instr, size_t frame_state_offset) {
InstructionOperandConverter i(this, instr);
int const state_id = i.InputInt32(frame_state_offset);
return code()->GetDeoptimizationEntry(state_id);
return instructions()->GetDeoptimizationEntry(state_id);
}
DeoptimizeKind CodeGenerator::GetDeoptimizationKind(
......
......@@ -89,7 +89,7 @@ class DeoptimizationLiteral {
class CodeGenerator final : public GapResolver::Assembler {
public:
explicit CodeGenerator(Zone* codegen_zone, Frame* frame, Linkage* linkage,
InstructionSequence* code,
InstructionSequence* instructions,
OptimizedCompilationInfo* info, Isolate* isolate,
base::Optional<OsrHelper> osr_helper,
int start_source_position,
......@@ -108,7 +108,7 @@ class CodeGenerator final : public GapResolver::Assembler {
OwnedVector<trap_handler::ProtectedInstructionData>
GetProtectedInstructions();
InstructionSequence* code() const { return code_; }
InstructionSequence* instructions() const { return instructions_; }
FrameAccessState* frame_access_state() const { return frame_access_state_; }
const Frame* frame() const { return frame_access_state_->frame(); }
Isolate* isolate() const { return isolate_; }
......@@ -402,7 +402,7 @@ class CodeGenerator final : public GapResolver::Assembler {
Isolate* isolate_;
FrameAccessState* frame_access_state_;
Linkage* const linkage_;
InstructionSequence* const code_;
InstructionSequence* const instructions_;
UnwindingInfoWriter unwinding_info_writer_;
OptimizedCompilationInfo* const info_;
Label* const labels_;
......
......@@ -382,7 +382,7 @@ class TestEnvironment : public HandleAndZoneScope {
TestEnvironment()
: blocks_(1, NewBlock(main_zone(), RpoNumber::FromInt(0)), main_zone()),
code_(main_isolate(), main_zone(), &blocks_),
instructions_(main_isolate(), main_zone(), &blocks_),
rng_(CcTest::random_number_generator()),
supported_reps_({MachineRepresentation::kTagged,
MachineRepresentation::kFloat32,
......@@ -573,8 +573,8 @@ class TestEnvironment : public HandleAndZoneScope {
}
int AllocateConstant(Constant constant) {
int virtual_register = code_.NextVirtualRegister();
code_.AddConstant(virtual_register, constant);
int virtual_register = instructions_.NextVirtualRegister();
instructions_.AddConstant(virtual_register, constant);
return virtual_register;
}
......@@ -721,8 +721,8 @@ class TestEnvironment : public HandleAndZoneScope {
OperandToStatePosition(AllocatedOperand::cast(move->destination()));
InstructionOperand from = move->source();
if (from.IsConstant()) {
Constant constant =
code_.GetConstant(ConstantOperand::cast(from).virtual_register());
Constant constant = instructions_.GetConstant(
ConstantOperand::cast(from).virtual_register());
Handle<Object> constant_value;
switch (constant.type()) {
case Constant::kInt32:
......@@ -924,13 +924,13 @@ class TestEnvironment : public HandleAndZoneScope {
}
v8::base::RandomNumberGenerator* rng() const { return rng_; }
InstructionSequence* code() { return &code_; }
InstructionSequence* instructions() { return &instructions_; }
CallDescriptor* test_descriptor() { return test_descriptor_; }
int stack_slot_count() const { return stack_slot_count_; }
private:
ZoneVector<InstructionBlock*> blocks_;
InstructionSequence code_;
InstructionSequence instructions_;
v8::base::RandomNumberGenerator* rng_;
// The layout describes the type of each element in the environment, in order.
std::vector<AllocatedOperand> layout_;
......@@ -995,9 +995,10 @@ class CodeGeneratorTester {
}
generator_ = new CodeGenerator(
environment->main_zone(), &frame_, &linkage_, environment->code(),
&info_, environment->main_isolate(), base::Optional<OsrHelper>(),
kNoSourcePosition, nullptr, PoisoningMitigationLevel::kDontPoison,
environment->main_zone(), &frame_, &linkage_,
environment->instructions(), &info_, environment->main_isolate(),
base::Optional<OsrHelper>(), kNoSourcePosition, nullptr,
PoisoningMitigationLevel::kDontPoison,
AssemblerOptions::Default(environment->main_isolate()),
Builtins::kNoBuiltinId);
......@@ -1123,7 +1124,7 @@ class CodeGeneratorTester {
generator_->AssembleMove(&move.second, &move.first);
}
InstructionSequence* sequence = generator_->code();
InstructionSequence* sequence = generator_->instructions();
sequence->StartBlock(RpoNumber::FromInt(0));
// The environment expects this code to tail-call to it's first parameter
......
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