Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Unified Diff: src/source-position.cc

Issue 2503393002: [cpu-profiler] use new source position information for deoptimization in cpu profiler (Closed)
Patch Set: addressed comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/source-position.h ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/source-position.cc
diff --git a/src/source-position.cc b/src/source-position.cc
index 0907ffe8e99626fe4b6315a0b5a83d3847964ec1..e9f86db01b3ed21853073aa4a6bf9546a889513d 100644
--- a/src/source-position.cc
+++ b/src/source-position.cc
@@ -10,28 +10,25 @@ namespace v8 {
namespace internal {
std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos) {
- Handle<SharedFunctionInfo> function;
- if (pos.function.ToHandle(&function)) {
- Handle<Script> script(Script::cast(function->script()));
- out << "<";
- if (script->name()->IsString()) {
- out << String::cast(script->name())->ToCString(DISALLOW_NULLS).get();
- } else {
- out << "unknown";
- }
- out << ":" << pos.line + 1 << ":" << pos.column + 1 << ">";
+ Handle<SharedFunctionInfo> function(pos.function);
+ Handle<Script> script(Script::cast(function->script()));
+ out << "<";
+ if (script->name()->IsString()) {
+ out << String::cast(script->name())->ToCString(DISALLOW_NULLS).get();
} else {
- out << "<unknown:" << pos.position.ScriptOffset() << ">";
+ out << "unknown";
}
+ out << ":" << pos.line + 1 << ":" << pos.column + 1 << ">";
return out;
}
std::ostream& operator<<(std::ostream& out,
const std::vector<SourcePositionInfo>& stack) {
- out << stack.back();
- for (int i = static_cast<int>(stack.size()) - 2; i >= 0; --i) {
- out << " inlined at ";
- out << stack[i];
+ bool first = true;
+ for (const SourcePositionInfo& pos : stack) {
+ if (!first) out << " inlined at ";
+ out << pos;
+ first = false;
}
return out;
}
@@ -48,51 +45,48 @@ std::ostream& operator<<(std::ostream& out, const SourcePosition& pos) {
SourcePositionInfo SourcePosition::Info(
Handle<SharedFunctionInfo> function) const {
+ SourcePositionInfo result(*this, function);
Handle<Script> script(Script::cast(function->script()));
- SourcePositionInfo result(*this);
Script::PositionInfo pos;
if (Script::GetPositionInfo(script, ScriptOffset(), &pos,
Script::WITH_OFFSET)) {
result.line = pos.line;
result.column = pos.column;
}
- result.function = function;
return result;
}
std::vector<SourcePositionInfo> SourcePosition::InliningStack(
CompilationInfo* cinfo) const {
- if (!isInlined()) {
- return std::vector<SourcePositionInfo>{Info(cinfo->shared_info())};
- } else {
- InliningPosition inl = cinfo->inlined_functions()[InliningId()].position;
- std::vector<SourcePositionInfo> stack = inl.position.InliningStack(cinfo);
- stack.push_back(Info(cinfo->inlined_functions()[InliningId()].shared_info));
- return stack;
+ SourcePosition pos = *this;
+ std::vector<SourcePositionInfo> stack;
+ while (pos.isInlined()) {
+ const auto& inl = cinfo->inlined_functions()[pos.InliningId()];
+ stack.push_back(pos.Info(inl.shared_info));
+ pos = inl.position.position;
}
+ stack.push_back(pos.Info(cinfo->shared_info()));
+ return stack;
}
std::vector<SourcePositionInfo> SourcePosition::InliningStack(
Handle<Code> code) const {
Handle<DeoptimizationInputData> deopt_data(
DeoptimizationInputData::cast(code->deoptimization_data()));
- if (!isInlined()) {
+ SourcePosition pos = *this;
+ std::vector<SourcePositionInfo> stack;
+ while (pos.isInlined()) {
+ InliningPosition inl =
+ deopt_data->InliningPositions()->get(pos.InliningId());
Handle<SharedFunctionInfo> function(
- SharedFunctionInfo::cast(deopt_data->SharedFunctionInfo()));
-
- return std::vector<SourcePositionInfo>{Info(function)};
- } else {
- InliningPosition inl = deopt_data->InliningPositions()->get(InliningId());
- std::vector<SourcePositionInfo> stack = inl.position.InliningStack(code);
- if (inl.inlined_function_id == -1) {
- stack.push_back(SourcePositionInfo(*this));
- } else {
- Handle<SharedFunctionInfo> function(SharedFunctionInfo::cast(
- deopt_data->LiteralArray()->get(inl.inlined_function_id)));
- stack.push_back(Info(function));
- }
- return stack;
+ deopt_data->GetInlinedFunction(inl.inlined_function_id));
+ stack.push_back(pos.Info(function));
+ pos = inl.position;
}
+ Handle<SharedFunctionInfo> function(
+ SharedFunctionInfo::cast(deopt_data->SharedFunctionInfo()));
+ stack.push_back(pos.Info(function));
+ return stack;
}
void SourcePosition::Print(std::ostream& out,
@@ -124,8 +118,8 @@ void SourcePosition::Print(std::ostream& out, Code* code) const {
if (inl.inlined_function_id == -1) {
out << *this;
} else {
- SharedFunctionInfo* function = SharedFunctionInfo::cast(
- deopt_data->LiteralArray()->get(inl.inlined_function_id));
+ SharedFunctionInfo* function =
+ deopt_data->GetInlinedFunction(inl.inlined_function_id);
Print(out, function);
}
out << " inlined at ";
« no previous file with comments | « src/source-position.h ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698