Commit dc3f240e authored by loislo's avatar loislo Committed by Commit bot

CpuProfiler: replace FLAG_hydrogen_track_positions with is_tracking_positions...

CpuProfiler: replace FLAG_hydrogen_track_positions with is_tracking_positions method on CompilationInfo

this is the second part of https://codereview.chromium.org/1012633002.

almost mechanical change.
I'd like to enable positions tracking when cpu profiler is working.
But I'll switch it on for cpu-profiler in another patch.

BUG=chromium:452067
LOG=n

Review URL: https://codereview.chromium.org/995183005

Cr-Commit-Position: refs/heads/master@{#27224}
parent ddfca2b0
...@@ -118,8 +118,10 @@ void CompilationInfo::Initialize(Isolate* isolate, ...@@ -118,8 +118,10 @@ void CompilationInfo::Initialize(Isolate* isolate,
? new List<OffsetRange>(2) : NULL; ? new List<OffsetRange>(2) : NULL;
if (FLAG_hydrogen_track_positions) { if (FLAG_hydrogen_track_positions) {
inlined_function_infos_ = new std::vector<InlinedFunctionInfo>(); inlined_function_infos_ = new std::vector<InlinedFunctionInfo>();
track_positions_ = true;
} else { } else {
inlined_function_infos_ = NULL; inlined_function_infos_ = NULL;
track_positions_ = false;
} }
for (int i = 0; i < DependentCode::kGroupCount; i++) { for (int i = 0; i < DependentCode::kGroupCount; i++) {
...@@ -276,7 +278,7 @@ bool CompilationInfo::is_simple_parameter_list() { ...@@ -276,7 +278,7 @@ bool CompilationInfo::is_simple_parameter_list() {
int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
SourcePosition position, SourcePosition position,
int parent_id) { int parent_id) {
DCHECK(FLAG_hydrogen_track_positions); DCHECK(track_positions_);
DCHECK(inlined_function_infos_); DCHECK(inlined_function_infos_);
int inline_id = static_cast<int>(inlined_function_infos_->size()); int inline_id = static_cast<int>(inlined_function_infos_->size());
...@@ -286,7 +288,7 @@ int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, ...@@ -286,7 +288,7 @@ int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
Handle<Script> script(Script::cast(shared->script())); Handle<Script> script(Script::cast(shared->script()));
info.script_id = script->id()->value(); info.script_id = script->id()->value();
if (!script->source()->IsUndefined()) { if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) {
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file()); OFStream os(tracing_scope.file());
os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get()
...@@ -308,7 +310,7 @@ int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, ...@@ -308,7 +310,7 @@ int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
inlined_function_infos_->push_back(info); inlined_function_infos_->push_back(info);
if (inline_id != 0) { if (FLAG_hydrogen_track_positions && inline_id != 0) {
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file()); OFStream os(tracing_scope.file());
os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{"
...@@ -480,9 +482,10 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() { ...@@ -480,9 +482,10 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
info()->shared_info()->disable_optimization_reason()); info()->shared_info()->disable_optimization_reason());
} }
graph_builder_ = (FLAG_hydrogen_track_positions || FLAG_trace_ic) graph_builder_ = (info()->is_tracking_positions() || FLAG_trace_ic)
? new(info()->zone()) HOptimizedGraphBuilderWithPositions(info()) ? new (info()->zone())
: new(info()->zone()) HOptimizedGraphBuilder(info()); HOptimizedGraphBuilderWithPositions(info())
: new (info()->zone()) HOptimizedGraphBuilder(info());
Timer t(this, &time_taken_to_create_graph_); Timer t(this, &time_taken_to_create_graph_);
// TODO(titzer): ParseInfo::this_has_uses is only used by Crankshaft. Move. // TODO(titzer): ParseInfo::this_has_uses is only used by Crankshaft. Move.
......
...@@ -168,6 +168,8 @@ class CompilationInfo { ...@@ -168,6 +168,8 @@ class CompilationInfo {
parameter_count_ = parameter_count; parameter_count_ = parameter_count;
} }
bool is_tracking_positions() const { return track_positions_; }
bool is_calling() const { bool is_calling() const {
return GetFlag(kDeferredCalling) || GetFlag(kNonDeferredCalling); return GetFlag(kDeferredCalling) || GetFlag(kNonDeferredCalling);
} }
...@@ -449,6 +451,7 @@ class CompilationInfo { ...@@ -449,6 +451,7 @@ class CompilationInfo {
List<OffsetRange>* no_frame_ranges_; List<OffsetRange>* no_frame_ranges_;
std::vector<InlinedFunctionInfo>* inlined_function_infos_; std::vector<InlinedFunctionInfo>* inlined_function_infos_;
bool track_positions_;
// A copy of shared_info()->opt_count() to avoid handle deref // A copy of shared_info()->opt_count() to avoid handle deref
// during graph optimization. // during graph optimization.
......
...@@ -3345,7 +3345,7 @@ HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) ...@@ -3345,7 +3345,7 @@ HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
// to know it's the initial state. // to know it's the initial state.
function_state_ = &initial_function_state_; function_state_ = &initial_function_state_;
InitializeAstVisitor(info->isolate(), info->zone()); InitializeAstVisitor(info->isolate(), info->zone());
if (FLAG_hydrogen_track_positions) { if (top_info()->is_tracking_positions()) {
SetSourcePosition(info->shared_info()->start_position()); SetSourcePosition(info->shared_info()->start_position());
} }
} }
...@@ -3450,7 +3450,7 @@ HGraph::HGraph(CompilationInfo* info) ...@@ -3450,7 +3450,7 @@ HGraph::HGraph(CompilationInfo* info)
start_environment_ = new (zone_) start_environment_ = new (zone_)
HEnvironment(zone_, descriptor.GetEnvironmentParameterCount()); HEnvironment(zone_, descriptor.GetEnvironmentParameterCount());
} else { } else {
if (FLAG_hydrogen_track_positions) { if (info->is_tracking_positions()) {
info->TraceInlinedFunction(info->shared_info(), SourcePosition::Unknown(), info->TraceInlinedFunction(info->shared_info(), SourcePosition::Unknown(),
InlinedFunctionInfo::kNoParentId); InlinedFunctionInfo::kNoParentId);
} }
...@@ -3911,7 +3911,7 @@ FunctionState::FunctionState(HOptimizedGraphBuilder* owner, ...@@ -3911,7 +3911,7 @@ FunctionState::FunctionState(HOptimizedGraphBuilder* owner,
// Push on the state stack. // Push on the state stack.
owner->set_function_state(this); owner->set_function_state(this);
if (FLAG_hydrogen_track_positions) { if (compilation_info_->is_tracking_positions()) {
outer_source_position_ = owner->source_position(); outer_source_position_ = owner->source_position();
owner->EnterInlinedSource( owner->EnterInlinedSource(
info->shared_info()->start_position(), info->shared_info()->start_position(),
...@@ -3925,7 +3925,7 @@ FunctionState::~FunctionState() { ...@@ -3925,7 +3925,7 @@ FunctionState::~FunctionState() {
delete test_context_; delete test_context_;
owner_->set_function_state(outer_); owner_->set_function_state(outer_);
if (FLAG_hydrogen_track_positions) { if (compilation_info_->is_tracking_positions()) {
owner_->set_source_position(outer_source_position_); owner_->set_source_position(outer_source_position_);
owner_->EnterInlinedSource( owner_->EnterInlinedSource(
outer_->compilation_info()->shared_info()->start_position(), outer_->compilation_info()->shared_info()->start_position(),
...@@ -6805,7 +6805,7 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) { ...@@ -6805,7 +6805,7 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) {
CHECK_ALIVE(VisitForValue(expr->exception())); CHECK_ALIVE(VisitForValue(expr->exception()));
HValue* value = environment()->Pop(); HValue* value = environment()->Pop();
if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
Add<HPushArguments>(value); Add<HPushArguments>(value);
Add<HCallRuntime>(isolate()->factory()->empty_string(), Add<HCallRuntime>(isolate()->factory()->empty_string(),
Runtime::FunctionForId(Runtime::kThrow), 1); Runtime::FunctionForId(Runtime::kThrow), 1);
...@@ -7926,17 +7926,17 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, ...@@ -7926,17 +7926,17 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
DCHECK(target_shared->has_deoptimization_support()); DCHECK(target_shared->has_deoptimization_support());
AstTyper::Run(&target_info); AstTyper::Run(&target_info);
int function_id = 0; int inlining_id = 0;
if (FLAG_hydrogen_track_positions) { if (top_info()->is_tracking_positions()) {
function_id = top_info()->TraceInlinedFunction( inlining_id = top_info()->TraceInlinedFunction(
target_shared, source_position(), function_state()->inlining_id()); target_shared, source_position(), function_state()->inlining_id());
} }
// Save the pending call context. Set up new one for the inlined function. // Save the pending call context. Set up new one for the inlined function.
// The function state is new-allocated because we need to delete it // The function state is new-allocated because we need to delete it
// in two different places. // in two different places.
FunctionState* target_state = new FunctionState( FunctionState* target_state =
this, &target_info, inlining_kind, function_id); new FunctionState(this, &target_info, inlining_kind, inlining_id);
HConstant* undefined = graph()->GetConstantUndefined(); HConstant* undefined = graph()->GetConstantUndefined();
...@@ -9425,7 +9425,7 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) { ...@@ -9425,7 +9425,7 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
DCHECK(!HasStackOverflow()); DCHECK(!HasStackOverflow());
DCHECK(current_block() != NULL); DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor()); DCHECK(current_block()->HasPredecessor());
if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
int argument_count = expr->arguments()->length() + 1; // Plus constructor. int argument_count = expr->arguments()->length() + 1; // Plus constructor.
Factory* factory = isolate()->factory(); Factory* factory = isolate()->factory();
...@@ -10104,7 +10104,7 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { ...@@ -10104,7 +10104,7 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) {
DCHECK(!HasStackOverflow()); DCHECK(!HasStackOverflow());
DCHECK(current_block() != NULL); DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor()); DCHECK(current_block()->HasPredecessor());
if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
Expression* target = expr->expression(); Expression* target = expr->expression();
VariableProxy* proxy = target->AsVariableProxy(); VariableProxy* proxy = target->AsVariableProxy();
Property* prop = target->AsProperty(); Property* prop = target->AsProperty();
...@@ -10760,7 +10760,7 @@ void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { ...@@ -10760,7 +10760,7 @@ void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) {
BuildBinaryOperation(expr, left, right, BuildBinaryOperation(expr, left, right,
ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE
: PUSH_BEFORE_SIMULATE); : PUSH_BEFORE_SIMULATE);
if (FLAG_hydrogen_track_positions && result->IsBinaryOperation()) { if (top_info()->is_tracking_positions() && result->IsBinaryOperation()) {
HBinaryOperation::cast(result)->SetOperandPositions( HBinaryOperation::cast(result)->SetOperandPositions(
zone(), zone(),
ScriptPositionToSourcePosition(expr->left()->position()), ScriptPositionToSourcePosition(expr->left()->position()),
...@@ -10798,7 +10798,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -10798,7 +10798,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
DCHECK(current_block() != NULL); DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor()); DCHECK(current_block()->HasPredecessor());
if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
// Check for a few fast cases. The AST visiting behavior must be in sync // 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 // with the full codegen: We don't push both left and right values onto
...@@ -10940,7 +10940,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( ...@@ -10940,7 +10940,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
AddCheckMap(operand_to_check, map); AddCheckMap(operand_to_check, map);
HCompareObjectEqAndBranch* result = HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right); New<HCompareObjectEqAndBranch>(left, right);
if (FLAG_hydrogen_track_positions) { if (top_info()->is_tracking_positions()) {
result->set_operand_position(zone(), 0, left_position); result->set_operand_position(zone(), 0, left_position);
result->set_operand_position(zone(), 1, right_position); result->set_operand_position(zone(), 1, right_position);
} }
...@@ -11006,7 +11006,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( ...@@ -11006,7 +11006,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
HCompareNumericAndBranch* result = HCompareNumericAndBranch* result =
New<HCompareNumericAndBranch>(left, right, op); New<HCompareNumericAndBranch>(left, right, op);
result->set_observed_input_representation(left_rep, right_rep); result->set_observed_input_representation(left_rep, right_rep);
if (FLAG_hydrogen_track_positions) { if (top_info()->is_tracking_positions()) {
result->SetOperandPositions(zone(), left_position, right_position); result->SetOperandPositions(zone(), left_position, right_position);
} }
return result; return result;
...@@ -11022,7 +11022,7 @@ void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, ...@@ -11022,7 +11022,7 @@ void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr,
DCHECK(current_block() != NULL); DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor()); DCHECK(current_block()->HasPredecessor());
DCHECK(expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT); DCHECK(expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT);
if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
CHECK_ALIVE(VisitForValue(sub_expr)); CHECK_ALIVE(VisitForValue(sub_expr));
HValue* value = Pop(); HValue* value = Pop();
if (expr->op() == Token::EQ_STRICT) { if (expr->op() == Token::EQ_STRICT) {
...@@ -13183,9 +13183,8 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { ...@@ -13183,9 +13183,8 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) {
PrintIndent(); PrintIndent();
std::ostringstream os; std::ostringstream os;
os << "0 " << uses << " " << NameOf(instruction) << " " << *instruction; os << "0 " << uses << " " << NameOf(instruction) << " " << *instruction;
if (FLAG_hydrogen_track_positions && if (graph->info()->is_tracking_positions() &&
instruction->has_position() && instruction->has_position() && instruction->position().raw() != 0) {
instruction->position().raw() != 0) {
const SourcePosition pos = instruction->position(); const SourcePosition pos = instruction->position();
os << " pos:"; os << " pos:";
if (pos.inlining_id() != 0) os << pos.inlining_id() << "_"; if (pos.inlining_id() != 0) os << pos.inlining_id() << "_";
......
...@@ -1874,7 +1874,7 @@ class HGraphBuilder { ...@@ -1874,7 +1874,7 @@ class HGraphBuilder {
} }
void EnterInlinedSource(int start_position, int id) { void EnterInlinedSource(int start_position, int id) {
if (FLAG_hydrogen_track_positions) { if (top_info()->is_tracking_positions()) {
start_position_ = start_position; start_position_ = start_position;
position_.set_inlining_id(id); position_.set_inlining_id(id);
} }
......
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