[turbofan] Add comments to CodeAssembler
Review-Url: https://codereview.chromium.org/2056503003 Cr-Commit-Position: refs/heads/master@{#36842}
This commit is contained in:
parent
fe561a7a18
commit
40b5c1d41f
@ -790,6 +790,8 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
|
||||
int base_size = JSArray::kSize + FixedArray::kHeaderSize;
|
||||
int elements_offset = JSArray::kSize;
|
||||
|
||||
Comment("begin allocation of JSArray");
|
||||
|
||||
if (allocation_site != nullptr) {
|
||||
base_size += AllocationMemento::kSize;
|
||||
elements_offset += AllocationMemento::kSize;
|
||||
|
@ -590,6 +590,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
case kArchDebugBreak:
|
||||
__ stop("kArchDebugBreak");
|
||||
break;
|
||||
case kArchComment: {
|
||||
Address comment_string = i.InputExternalReference(0).address();
|
||||
__ RecordComment(reinterpret_cast<const char*>(comment_string));
|
||||
break;
|
||||
}
|
||||
case kArchNop:
|
||||
case kArchThrowTerminator:
|
||||
// don't emit code for nops.
|
||||
|
@ -717,6 +717,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
case kArchDebugBreak:
|
||||
__ Debug("kArchDebugBreak", 0, BREAK);
|
||||
break;
|
||||
case kArchComment: {
|
||||
Address comment_string = i.InputExternalReference(0).address();
|
||||
__ RecordComment(reinterpret_cast<const char*>(comment_string));
|
||||
break;
|
||||
}
|
||||
case kArchNop:
|
||||
case kArchThrowTerminator:
|
||||
// don't emit code for nops.
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "src/interpreter/bytecodes.h"
|
||||
#include "src/machine-type.h"
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/utils.h"
|
||||
#include "src/zone.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -162,6 +163,25 @@ void CodeAssembler::Return(Node* value) {
|
||||
|
||||
void CodeAssembler::DebugBreak() { raw_assembler_->DebugBreak(); }
|
||||
|
||||
void CodeAssembler::Comment(const char* format, ...) {
|
||||
if (!FLAG_code_comments) return;
|
||||
char buffer[4 * KB];
|
||||
StringBuilder builder(buffer, arraysize(buffer));
|
||||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
builder.AddFormattedList(format, arguments);
|
||||
va_end(arguments);
|
||||
|
||||
// Copy the string before recording it in the assembler to avoid
|
||||
// issues when the stack allocated buffer goes out of scope.
|
||||
size_t length = builder.position() + 3;
|
||||
char* copy = reinterpret_cast<char*>(malloc(static_cast<int>(length)));
|
||||
MemCopy(copy + 2, builder.Finalize(), length);
|
||||
copy[0] = ';';
|
||||
copy[1] = ' ';
|
||||
raw_assembler_->Comment(copy);
|
||||
}
|
||||
|
||||
void CodeAssembler::Bind(CodeAssembler::Label* label) { return label->Bind(); }
|
||||
|
||||
Node* CodeAssembler::LoadFramePointer() {
|
||||
|
@ -212,6 +212,7 @@ class CodeAssembler {
|
||||
void Return(Node* value);
|
||||
|
||||
void DebugBreak();
|
||||
void Comment(const char* format, ...);
|
||||
|
||||
void Bind(Label* label);
|
||||
void Goto(Label* label);
|
||||
|
@ -539,6 +539,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
case kArchTableSwitch:
|
||||
AssembleArchTableSwitch(instr);
|
||||
break;
|
||||
case kArchComment: {
|
||||
Address comment_string = i.InputExternalReference(0).address();
|
||||
__ RecordComment(reinterpret_cast<const char*>(comment_string));
|
||||
break;
|
||||
}
|
||||
case kArchDebugBreak:
|
||||
__ int3();
|
||||
break;
|
||||
|
@ -57,6 +57,7 @@ enum class RecordWriteMode { kValueIsMap, kValueIsPointer, kValueIsAny };
|
||||
V(ArchTableSwitch) \
|
||||
V(ArchNop) \
|
||||
V(ArchDebugBreak) \
|
||||
V(ArchComment) \
|
||||
V(ArchThrowTerminator) \
|
||||
V(ArchDeoptimize) \
|
||||
V(ArchRet) \
|
||||
|
@ -223,6 +223,7 @@ int InstructionScheduler::GetInstructionFlags(const Instruction* instr) const {
|
||||
case kArchTruncateDoubleToI:
|
||||
case kArchStackSlot:
|
||||
case kArchDebugBreak:
|
||||
case kArchComment:
|
||||
return kNoOpcodeFlags;
|
||||
|
||||
case kArchStackPointer:
|
||||
|
@ -219,6 +219,7 @@ class OperandGenerator {
|
||||
case IrOpcode::kNumberConstant:
|
||||
return Constant(OpParameter<double>(node));
|
||||
case IrOpcode::kExternalConstant:
|
||||
case IrOpcode::kComment:
|
||||
return Constant(OpParameter<ExternalReference>(node));
|
||||
case IrOpcode::kHeapConstant:
|
||||
return Constant(OpParameter<Handle<HeapObject>>(node));
|
||||
|
@ -907,7 +907,10 @@ void InstructionSelector::VisitNode(Node* node) {
|
||||
case IrOpcode::kObjectState:
|
||||
return;
|
||||
case IrOpcode::kDebugBreak:
|
||||
VisitDebugBreak();
|
||||
VisitDebugBreak(node);
|
||||
return;
|
||||
case IrOpcode::kComment:
|
||||
VisitComment(node);
|
||||
return;
|
||||
case IrOpcode::kLoad: {
|
||||
LoadRepresentation type = LoadRepresentationOf(node->op());
|
||||
@ -1800,11 +1803,17 @@ void InstructionSelector::VisitThrow(Node* value) {
|
||||
Emit(kArchThrowTerminator, g.NoOutput());
|
||||
}
|
||||
|
||||
void InstructionSelector::VisitDebugBreak() {
|
||||
void InstructionSelector::VisitDebugBreak(Node* node) {
|
||||
OperandGenerator g(this);
|
||||
Emit(kArchDebugBreak, g.NoOutput());
|
||||
}
|
||||
|
||||
void InstructionSelector::VisitComment(Node* node) {
|
||||
OperandGenerator g(this);
|
||||
InstructionOperand operand(g.UseImmediate(node));
|
||||
Emit(kArchComment, 0, nullptr, 1, &operand);
|
||||
}
|
||||
|
||||
FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor(
|
||||
Node* state) {
|
||||
DCHECK(state->opcode() == IrOpcode::kFrameState);
|
||||
|
@ -265,7 +265,6 @@ class InstructionSelector final {
|
||||
void VisitDeoptimize(DeoptimizeKind kind, Node* value);
|
||||
void VisitReturn(Node* ret);
|
||||
void VisitThrow(Node* value);
|
||||
void VisitDebugBreak();
|
||||
|
||||
void EmitPrepareArguments(ZoneVector<compiler::PushParameter>* arguments,
|
||||
const CallDescriptor* descriptor, Node* node);
|
||||
|
@ -538,6 +538,11 @@ struct MachineOperatorGlobalCache {
|
||||
DebugBreakOperator kDebugBreak;
|
||||
};
|
||||
|
||||
struct CommentOperator : public Operator1<const char*> {
|
||||
explicit CommentOperator(const char* msg)
|
||||
: Operator1<const char*>(IrOpcode::kComment, Operator::kNoThrow,
|
||||
"Comment", 0, 0, 0, 0, 0, 0, msg) {}
|
||||
};
|
||||
|
||||
static base::LazyInstance<MachineOperatorGlobalCache>::type kCache =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
@ -545,7 +550,8 @@ static base::LazyInstance<MachineOperatorGlobalCache>::type kCache =
|
||||
MachineOperatorBuilder::MachineOperatorBuilder(
|
||||
Zone* zone, MachineRepresentation word, Flags flags,
|
||||
AlignmentRequirements alignmentRequirements)
|
||||
: cache_(kCache.Get()),
|
||||
: zone_(zone),
|
||||
cache_(kCache.Get()),
|
||||
word_(word),
|
||||
flags_(flags),
|
||||
alignment_requirements_(alignmentRequirements) {
|
||||
@ -620,6 +626,10 @@ const Operator* MachineOperatorBuilder::DebugBreak() {
|
||||
return &cache_.kDebugBreak;
|
||||
}
|
||||
|
||||
const Operator* MachineOperatorBuilder::Comment(const char* msg) {
|
||||
return new (zone_) CommentOperator(msg);
|
||||
}
|
||||
|
||||
const Operator* MachineOperatorBuilder::CheckedLoad(
|
||||
CheckedLoadRepresentation rep) {
|
||||
#define LOAD(Type) \
|
||||
|
@ -194,6 +194,7 @@ class MachineOperatorBuilder final : public ZoneObject {
|
||||
AlignmentRequirements alignmentRequirements =
|
||||
AlignmentRequirements::NoUnalignedAccessSupport());
|
||||
|
||||
const Operator* Comment(const char* msg);
|
||||
const Operator* DebugBreak();
|
||||
|
||||
const Operator* Word32And();
|
||||
@ -631,6 +632,7 @@ class MachineOperatorBuilder final : public ZoneObject {
|
||||
#undef PSEUDO_OP_LIST
|
||||
|
||||
private:
|
||||
Zone* zone_;
|
||||
MachineOperatorGlobalCache const& cache_;
|
||||
MachineRepresentation const word_;
|
||||
Flags const flags_;
|
||||
|
@ -655,6 +655,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
case kArchDebugBreak:
|
||||
__ stop("kArchDebugBreak");
|
||||
break;
|
||||
case kArchComment: {
|
||||
Address comment_string = i.InputExternalReference(0).address();
|
||||
__ RecordComment(reinterpret_cast<const char*>(comment_string));
|
||||
break;
|
||||
}
|
||||
case kArchNop:
|
||||
case kArchThrowTerminator:
|
||||
// don't emit code for nops.
|
||||
|
@ -664,6 +664,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
case kArchDebugBreak:
|
||||
__ stop("kArchDebugBreak");
|
||||
break;
|
||||
case kArchComment: {
|
||||
Address comment_string = i.InputExternalReference(0).address();
|
||||
__ RecordComment(reinterpret_cast<const char*>(comment_string));
|
||||
break;
|
||||
}
|
||||
case kArchNop:
|
||||
case kArchThrowTerminator:
|
||||
// don't emit code for nops.
|
||||
|
@ -256,6 +256,7 @@
|
||||
#define MACHINE_OP_LIST(V) \
|
||||
MACHINE_COMPARE_BINOP_LIST(V) \
|
||||
V(DebugBreak) \
|
||||
V(Comment) \
|
||||
V(Load) \
|
||||
V(Store) \
|
||||
V(StackSlot) \
|
||||
|
@ -137,6 +137,10 @@ void RawMachineAssembler::Return(Node* v1, Node* v2, Node* v3) {
|
||||
|
||||
void RawMachineAssembler::DebugBreak() { AddNode(machine()->DebugBreak()); }
|
||||
|
||||
void RawMachineAssembler::Comment(const char* msg) {
|
||||
AddNode(machine()->Comment(msg));
|
||||
}
|
||||
|
||||
Node* RawMachineAssembler::CallN(CallDescriptor* desc, Node* function,
|
||||
Node** args) {
|
||||
int param_count =
|
||||
|
@ -699,6 +699,7 @@ class RawMachineAssembler {
|
||||
void Bind(RawMachineLabel* label);
|
||||
void Deoptimize(Node* state);
|
||||
void DebugBreak();
|
||||
void Comment(const char* msg);
|
||||
|
||||
// Variables.
|
||||
Node* Phi(MachineRepresentation rep, Node* n1, Node* n2) {
|
||||
|
@ -2080,6 +2080,8 @@ Type* Typer::Visitor::TypeObjectIsUndetectable(Node* node) {
|
||||
|
||||
Type* Typer::Visitor::TypeDebugBreak(Node* node) { return Type::None(); }
|
||||
|
||||
Type* Typer::Visitor::TypeComment(Node* node) { return Type::None(); }
|
||||
|
||||
Type* Typer::Visitor::TypeLoad(Node* node) { return Type::Any(); }
|
||||
|
||||
Type* Typer::Visitor::TypeStackSlot(Node* node) { return Type::Any(); }
|
||||
|
@ -658,6 +658,10 @@ void Verifier::Visitor::Check(Node* node) {
|
||||
CheckNotTyped(node);
|
||||
break;
|
||||
|
||||
case IrOpcode::kComment:
|
||||
CheckNotTyped(node);
|
||||
break;
|
||||
|
||||
// Simplified operators
|
||||
// -------------------------------
|
||||
case IrOpcode::kBooleanNot:
|
||||
|
@ -759,6 +759,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
case kArchTableSwitch:
|
||||
AssembleArchTableSwitch(instr);
|
||||
break;
|
||||
case kArchComment: {
|
||||
Address comment_string = i.InputExternalReference(0).address();
|
||||
__ RecordComment(reinterpret_cast<const char*>(comment_string));
|
||||
break;
|
||||
}
|
||||
case kArchDebugBreak:
|
||||
__ int3();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user