Commit c615b6ee authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[crankshaft] Move is_tracking_positions predicate.

This moves the Hydrogen-specific {is_tracking_positions} predicate which
also depends on the --hydrogen-track-positions flag into the Crankshaft
directory and removes it from the more general {CompilationInfo}.

R=bmeurer@chromium.org

Review-Url: https://codereview.chromium.org/2377283002
Cr-Commit-Position: refs/heads/master@{#39913}
parent eb582256
......@@ -38,7 +38,7 @@ static LChunk* OptimizeGraph(HGraph* graph) {
class CodeStubGraphBuilderBase : public HGraphBuilder {
public:
explicit CodeStubGraphBuilderBase(CompilationInfo* info, CodeStub* code_stub)
: HGraphBuilder(info, code_stub->GetCallInterfaceDescriptor()),
: HGraphBuilder(info, code_stub->GetCallInterfaceDescriptor(), false),
arguments_length_(NULL),
info_(info),
code_stub_(code_stub),
......
......@@ -75,8 +75,6 @@ CompilationInfo::CompilationInfo(ParseInfo* parse_info,
dependencies_(isolate, zone),
bailout_reason_(kNoReason),
prologue_offset_(Code::kPrologueOffsetNotSet),
track_positions_(FLAG_hydrogen_track_positions ||
isolate->is_profiling()),
parameter_count_(0),
optimization_id_(-1),
osr_expr_stack_height_(-1),
......
......@@ -92,8 +92,6 @@ class CompilationInfo final {
bool has_bytecode_array() const { return !bytecode_array_.is_null(); }
Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
bool is_tracking_positions() const { return track_positions_; }
bool is_calling() const {
return GetFlag(kDeferredCalling) || GetFlag(kNonDeferredCalling);
}
......@@ -379,8 +377,6 @@ class CompilationInfo final {
int prologue_offset_;
bool track_positions_;
InlinedFunctionList inlined_functions_;
// Number of parameters used for compilation of stubs that require arguments.
......
......@@ -75,7 +75,9 @@ const auto GetRegConfig = RegisterConfiguration::Crankshaft;
class HOptimizedGraphBuilderWithPositions : public HOptimizedGraphBuilder {
public:
explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
: HOptimizedGraphBuilder(info) {}
: HOptimizedGraphBuilder(info, true) {
SetSourcePosition(info->shared_info()->start_position());
}
#define DEF_VISIT(type) \
void Visit##type(type* node) override { \
......@@ -178,9 +180,10 @@ HCompilationJob::Status HCompilationJob::PrepareJobImpl() {
}
HOptimizedGraphBuilder* graph_builder =
(info()->is_tracking_positions() || FLAG_trace_ic)
(FLAG_hydrogen_track_positions || isolate()->is_profiling() ||
FLAG_trace_ic)
? new (info()->zone()) HOptimizedGraphBuilderWithPositions(info())
: new (info()->zone()) HOptimizedGraphBuilder(info());
: new (info()->zone()) HOptimizedGraphBuilder(info(), false);
// Type-check the function.
AstTyper(info()->isolate(), info()->zone(), info()->closure(),
......@@ -1362,7 +1365,7 @@ HGraph* HGraphBuilder::CreateGraph() {
DCHECK(!FLAG_minimal);
graph_ = new (zone()) HGraph(info_, descriptor_);
if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_);
if (!info_->IsStub() && info_->is_tracking_positions()) {
if (!info_->IsStub() && is_tracking_positions()) {
TraceInlinedFunction(info_->shared_info(), SourcePosition::Unknown());
}
CompilationPhase phase("H_Block building", info_);
......@@ -1374,7 +1377,7 @@ HGraph* HGraphBuilder::CreateGraph() {
int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
SourcePosition position) {
DCHECK(info_->is_tracking_positions());
DCHECK(is_tracking_positions());
int inline_id = static_cast<int>(graph()->inlined_function_infos().size());
HInlinedFunctionInfo info(shared->start_position());
......@@ -3366,8 +3369,9 @@ HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) {
return Add<HLoadNamedField>(native_context, nullptr, function_access);
}
HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
: HGraphBuilder(info, CallInterfaceDescriptor()),
HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info,
bool track_positions)
: HGraphBuilder(info, CallInterfaceDescriptor(), track_positions),
function_state_(NULL),
initial_function_state_(this, info, NORMAL_RETURN, 0,
TailCallMode::kAllow),
......@@ -3382,9 +3386,6 @@ HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
// to know it's the initial state.
function_state_ = &initial_function_state_;
InitializeAstVisitor(info->isolate());
if (top_info()->is_tracking_positions()) {
SetSourcePosition(info->shared_info()->start_position());
}
}
......@@ -3951,7 +3952,7 @@ FunctionState::FunctionState(HOptimizedGraphBuilder* owner,
// Push on the state stack.
owner->set_function_state(this);
if (compilation_info_->is_tracking_positions()) {
if (owner->is_tracking_positions()) {
outer_source_position_ = owner->source_position();
owner->EnterInlinedSource(
info->shared_info()->start_position(),
......@@ -3965,7 +3966,7 @@ FunctionState::~FunctionState() {
delete test_context_;
owner_->set_function_state(outer_);
if (compilation_info_->is_tracking_positions()) {
if (owner_->is_tracking_positions()) {
owner_->set_source_position(outer_source_position_);
owner_->EnterInlinedSource(
outer_->compilation_info()->shared_info()->start_position(),
......@@ -7037,7 +7038,7 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) {
CHECK_ALIVE(VisitForValue(expr->exception()));
HValue* value = environment()->Pop();
if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
if (!is_tracking_positions()) SetSourcePosition(expr->position());
Add<HPushArguments>(value);
Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kThrow), 1);
Add<HSimulate>(expr->id());
......@@ -8343,7 +8344,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
.Run();
int inlining_id = 0;
if (top_info()->is_tracking_positions()) {
if (is_tracking_positions()) {
inlining_id = TraceInlinedFunction(target_shared, source_position());
}
......@@ -8392,7 +8393,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
return_id, target, context, arguments_count, function,
function_state()->inlining_kind(), function->scope()->arguments(),
arguments_object, syntactic_tail_call_mode);
if (top_info()->is_tracking_positions()) {
if (is_tracking_positions()) {
enter_inlined->set_inlining_id(inlining_id);
}
function_state()->set_entry(enter_inlined);
......@@ -9591,7 +9592,7 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
DCHECK(!HasStackOverflow());
DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor());
if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
if (!is_tracking_positions()) SetSourcePosition(expr->position());
Expression* callee = expr->expression();
int argument_count = expr->arguments()->length() + 1; // Plus receiver.
HInstruction* call = NULL;
......@@ -9873,7 +9874,7 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
DCHECK(!HasStackOverflow());
DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor());
if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
if (!is_tracking_positions()) SetSourcePosition(expr->position());
int argument_count = expr->arguments()->length() + 1; // Plus constructor.
Factory* factory = isolate()->factory();
......@@ -10600,7 +10601,7 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) {
DCHECK(!HasStackOverflow());
DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor());
if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
if (!is_tracking_positions()) SetSourcePosition(expr->position());
Expression* target = expr->expression();
VariableProxy* proxy = target->AsVariableProxy();
Property* prop = target->AsProperty();
......@@ -11316,7 +11317,7 @@ void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) {
BuildBinaryOperation(expr, left, right,
ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE
: PUSH_BEFORE_SIMULATE);
if (top_info()->is_tracking_positions() && result->IsBinaryOperation()) {
if (is_tracking_positions() && result->IsBinaryOperation()) {
HBinaryOperation::cast(result)->SetOperandPositions(
zone(),
ScriptPositionToSourcePosition(expr->left()->position()),
......@@ -11358,7 +11359,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor());
if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
if (!is_tracking_positions()) SetSourcePosition(expr->position());
// Check for a few fast cases. The AST visiting behavior must be in sync
// with the full codegen: We don't push both left and right values onto
......@@ -11501,7 +11502,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
AddCheckMap(operand_to_check, map);
HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right);
if (top_info()->is_tracking_positions()) {
if (is_tracking_positions()) {
result->set_operand_position(zone(), 0, left_position);
result->set_operand_position(zone(), 1, right_position);
}
......@@ -11644,7 +11645,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
HCompareNumericAndBranch* result =
New<HCompareNumericAndBranch>(left, right, op);
result->set_observed_input_representation(left_rep, right_rep);
if (top_info()->is_tracking_positions()) {
if (is_tracking_positions()) {
result->SetOperandPositions(zone(), left_position, right_position);
}
return result;
......@@ -11660,7 +11661,7 @@ void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr,
DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor());
DCHECK(expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT);
if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
if (!is_tracking_positions()) SetSourcePosition(expr->position());
CHECK_ALIVE(VisitForValue(sub_expr));
HValue* value = Pop();
HControlInstruction* instr;
......@@ -13073,8 +13074,7 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) {
PrintIndent();
std::ostringstream os;
os << "0 " << uses << " " << NameOf(instruction) << " " << *instruction;
if (graph->info()->is_tracking_positions() &&
instruction->has_position() && instruction->position().raw() != 0) {
if (instruction->has_position() && instruction->position().raw() != 0) {
const SourcePosition pos = instruction->position();
os << " pos:";
if (pos.inlining_id() != 0) os << pos.inlining_id() << "_";
......
......@@ -1065,14 +1065,16 @@ class HAllocationMode final BASE_EMBEDDED {
class HGraphBuilder {
public:
explicit HGraphBuilder(CompilationInfo* info,
CallInterfaceDescriptor descriptor)
CallInterfaceDescriptor descriptor,
bool track_positions)
: info_(info),
descriptor_(descriptor),
graph_(NULL),
current_block_(NULL),
scope_(info->scope()),
position_(SourcePosition::Unknown()),
start_position_(0) {}
start_position_(0),
track_positions_(track_positions) {}
virtual ~HGraphBuilder() {}
Scope* scope() const { return scope_; }
......@@ -1874,7 +1876,7 @@ class HGraphBuilder {
}
void EnterInlinedSource(int start_position, int id) {
if (top_info()->is_tracking_positions()) {
if (is_tracking_positions()) {
start_position_ = start_position;
position_.set_inlining_id(id);
}
......@@ -1895,6 +1897,8 @@ class HGraphBuilder {
SourcePosition source_position() { return position_; }
void set_source_position(SourcePosition position) { position_ = position; }
bool is_tracking_positions() { return track_positions_; }
int TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
SourcePosition position);
......@@ -1920,6 +1924,7 @@ class HGraphBuilder {
Scope* scope_;
SourcePosition position_;
int start_position_;
bool track_positions_;
};
template <>
......@@ -2117,7 +2122,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder,
BreakAndContinueScope* next_;
};
explicit HOptimizedGraphBuilder(CompilationInfo* info);
explicit HOptimizedGraphBuilder(CompilationInfo* info, bool track_positions);
bool BuildGraph() override;
......
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