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

CpuProfiler: do not calculate positions if it is not necessary (TryInline part).

TryInline needed position only for the case when we track positions.
We can drop the position argument and use the current position from GraphBuilder.
The only problem that it doesn't match with the inline point.
The reason of that was the fact that builder had moved the position forward by
visiting arguments expressions.

I fixed this by restoring the current positon in HOptimizedGraphBuilderWithPositions::Visit*

BUG=452067
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#26953}
parent 6130b025
...@@ -336,9 +336,7 @@ bool CompilationInfo::is_simple_parameter_list() { ...@@ -336,9 +336,7 @@ bool CompilationInfo::is_simple_parameter_list() {
int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
SourcePosition position) { SourcePosition position) {
if (!FLAG_hydrogen_track_positions) { DCHECK(FLAG_hydrogen_track_positions);
return 0;
}
DCHECK(inlined_function_infos_); DCHECK(inlined_function_infos_);
DCHECK(inlining_id_to_function_id_); DCHECK(inlining_id_to_function_id_);
...@@ -395,22 +393,32 @@ class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { ...@@ -395,22 +393,32 @@ class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
: HOptimizedGraphBuilder(info) { : HOptimizedGraphBuilder(info) {
} }
#define DEF_VISIT(type) \ #define DEF_VISIT(type) \
void Visit##type(type* node) OVERRIDE { \ void Visit##type(type* node) OVERRIDE { \
if (node->position() != RelocInfo::kNoPosition) { \ SourcePosition old_position = SourcePosition::Unknown(); \
SetSourcePosition(node->position()); \ if (node->position() != RelocInfo::kNoPosition) { \
} \ old_position = source_position(); \
HOptimizedGraphBuilder::Visit##type(node); \ SetSourcePosition(node->position()); \
} \
HOptimizedGraphBuilder::Visit##type(node); \
if (!old_position.IsUnknown()) { \
set_source_position(old_position); \
} \
} }
EXPRESSION_NODE_LIST(DEF_VISIT) EXPRESSION_NODE_LIST(DEF_VISIT)
#undef DEF_VISIT #undef DEF_VISIT
#define DEF_VISIT(type) \ #define DEF_VISIT(type) \
void Visit##type(type* node) OVERRIDE { \ void Visit##type(type* node) OVERRIDE { \
if (node->position() != RelocInfo::kNoPosition) { \ SourcePosition old_position = SourcePosition::Unknown(); \
SetSourcePosition(node->position()); \ if (node->position() != RelocInfo::kNoPosition) { \
} \ old_position = source_position(); \
HOptimizedGraphBuilder::Visit##type(node); \ SetSourcePosition(node->position()); \
} \
HOptimizedGraphBuilder::Visit##type(node); \
if (!old_position.IsUnknown()) { \
set_source_position(old_position); \
} \
} }
STATEMENT_NODE_LIST(DEF_VISIT) STATEMENT_NODE_LIST(DEF_VISIT)
#undef DEF_VISIT #undef DEF_VISIT
......
...@@ -3453,7 +3453,10 @@ HGraph::HGraph(CompilationInfo* info) ...@@ -3453,7 +3453,10 @@ HGraph::HGraph(CompilationInfo* info)
start_environment_ = new (zone_) start_environment_ = new (zone_)
HEnvironment(zone_, descriptor.GetEnvironmentParameterCount()); HEnvironment(zone_, descriptor.GetEnvironmentParameterCount());
} else { } else {
info->TraceInlinedFunction(info->shared_info(), SourcePosition::Unknown()); if (FLAG_hydrogen_track_positions) {
info->TraceInlinedFunction(info->shared_info(),
SourcePosition::Unknown());
}
start_environment_ = start_environment_ =
new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_);
} }
...@@ -7794,8 +7797,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, ...@@ -7794,8 +7797,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
int arguments_count, int arguments_count,
HValue* implicit_return_value, HValue* implicit_return_value,
BailoutId ast_id, BailoutId return_id, BailoutId ast_id, BailoutId return_id,
InliningKind inlining_kind, InliningKind inlining_kind) {
SourcePosition position) {
int nodes_added = InliningAstSize(target); int nodes_added = InliningAstSize(target);
if (nodes_added == kNotInlinable) return false; if (nodes_added == kNotInlinable) return false;
...@@ -7907,7 +7909,11 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, ...@@ -7907,7 +7909,11 @@ 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 = top_info()->TraceInlinedFunction(target_shared, position); int function_id = 0;
if (FLAG_hydrogen_track_positions) {
function_id =
top_info()->TraceInlinedFunction(target_shared, source_position());
}
// 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
...@@ -8063,25 +8069,16 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, ...@@ -8063,25 +8069,16 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
bool HOptimizedGraphBuilder::TryInlineCall(Call* expr) { bool HOptimizedGraphBuilder::TryInlineCall(Call* expr) {
return TryInline(expr->target(), return TryInline(expr->target(), expr->arguments()->length(), NULL,
expr->arguments()->length(), expr->id(), expr->ReturnId(), NORMAL_RETURN);
NULL,
expr->id(),
expr->ReturnId(),
NORMAL_RETURN,
ScriptPositionToSourcePosition(expr->position()));
} }
bool HOptimizedGraphBuilder::TryInlineConstruct(CallNew* expr, bool HOptimizedGraphBuilder::TryInlineConstruct(CallNew* expr,
HValue* implicit_return_value) { HValue* implicit_return_value) {
return TryInline(expr->target(), return TryInline(expr->target(), expr->arguments()->length(),
expr->arguments()->length(), implicit_return_value, expr->id(), expr->ReturnId(),
implicit_return_value, CONSTRUCT_CALL_RETURN);
expr->id(),
expr->ReturnId(),
CONSTRUCT_CALL_RETURN,
ScriptPositionToSourcePosition(expr->position()));
} }
...@@ -8090,13 +8087,7 @@ bool HOptimizedGraphBuilder::TryInlineGetter(Handle<JSFunction> getter, ...@@ -8090,13 +8087,7 @@ bool HOptimizedGraphBuilder::TryInlineGetter(Handle<JSFunction> getter,
BailoutId ast_id, BailoutId ast_id,
BailoutId return_id) { BailoutId return_id) {
if (TryInlineApiGetter(getter, receiver_map, ast_id)) return true; if (TryInlineApiGetter(getter, receiver_map, ast_id)) return true;
return TryInline(getter, return TryInline(getter, 0, NULL, ast_id, return_id, GETTER_CALL_RETURN);
0,
NULL,
ast_id,
return_id,
GETTER_CALL_RETURN,
source_position());
} }
...@@ -8106,25 +8097,16 @@ bool HOptimizedGraphBuilder::TryInlineSetter(Handle<JSFunction> setter, ...@@ -8106,25 +8097,16 @@ bool HOptimizedGraphBuilder::TryInlineSetter(Handle<JSFunction> setter,
BailoutId assignment_id, BailoutId assignment_id,
HValue* implicit_return_value) { HValue* implicit_return_value) {
if (TryInlineApiSetter(setter, receiver_map, id)) return true; if (TryInlineApiSetter(setter, receiver_map, id)) return true;
return TryInline(setter, return TryInline(setter, 1, implicit_return_value, id, assignment_id,
1, SETTER_CALL_RETURN);
implicit_return_value,
id, assignment_id,
SETTER_CALL_RETURN,
source_position());
} }
bool HOptimizedGraphBuilder::TryInlineIndirectCall(Handle<JSFunction> function, bool HOptimizedGraphBuilder::TryInlineIndirectCall(Handle<JSFunction> function,
Call* expr, Call* expr,
int arguments_count) { int arguments_count) {
return TryInline(function, return TryInline(function, arguments_count, NULL, expr->id(),
arguments_count, expr->ReturnId(), NORMAL_RETURN);
NULL,
expr->id(),
expr->ReturnId(),
NORMAL_RETURN,
ScriptPositionToSourcePosition(expr->position()));
} }
...@@ -9152,8 +9134,6 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) { ...@@ -9152,8 +9134,6 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
CHECK_ALIVE(PushLoad(prop, receiver, key)); CHECK_ALIVE(PushLoad(prop, receiver, key));
HValue* function = Pop(); HValue* function = Pop();
if (FLAG_hydrogen_track_positions) SetSourcePosition(expr->position());
if (function->IsConstant() && if (function->IsConstant() &&
HConstant::cast(function)->handle(isolate())->IsJSFunction()) { HConstant::cast(function)->handle(isolate())->IsJSFunction()) {
// Push the function under the receiver. // Push the function under the receiver.
...@@ -10861,8 +10841,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -10861,8 +10841,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
CHECK_ALIVE(VisitForValue(expr->left())); CHECK_ALIVE(VisitForValue(expr->left()));
CHECK_ALIVE(VisitForValue(expr->right())); CHECK_ALIVE(VisitForValue(expr->right()));
if (FLAG_hydrogen_track_positions) SetSourcePosition(expr->position());
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
Token::Value op = expr->op(); Token::Value op = expr->op();
......
...@@ -2319,8 +2319,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -2319,8 +2319,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
int InliningAstSize(Handle<JSFunction> target); int InliningAstSize(Handle<JSFunction> target);
bool TryInline(Handle<JSFunction> target, int arguments_count, bool TryInline(Handle<JSFunction> target, int arguments_count,
HValue* implicit_return_value, BailoutId ast_id, HValue* implicit_return_value, BailoutId ast_id,
BailoutId return_id, InliningKind inlining_kind, BailoutId return_id, InliningKind inlining_kind);
SourcePosition position);
bool TryInlineCall(Call* expr); bool TryInlineCall(Call* expr);
bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value);
......
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