[source-positions] make the SourcePositionInfo constructor actually compute position info
R=danno@chromium.org BUG= Review-Url: https://codereview.chromium.org/2568303008 Cr-Commit-Position: refs/heads/master@{#41693}
This commit is contained in:
parent
f39665e360
commit
859414da4c
@ -43,29 +43,16 @@ std::ostream& operator<<(std::ostream& out, const SourcePosition& pos) {
|
||||
return out;
|
||||
}
|
||||
|
||||
SourcePositionInfo SourcePosition::Info(
|
||||
Handle<SharedFunctionInfo> function) const {
|
||||
SourcePositionInfo result(*this, function);
|
||||
Handle<Script> script(Script::cast(function->script()));
|
||||
Script::PositionInfo pos;
|
||||
if (Script::GetPositionInfo(script, ScriptOffset(), &pos,
|
||||
Script::WITH_OFFSET)) {
|
||||
result.line = pos.line;
|
||||
result.column = pos.column;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<SourcePositionInfo> SourcePosition::InliningStack(
|
||||
CompilationInfo* cinfo) const {
|
||||
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));
|
||||
stack.push_back(SourcePositionInfo(pos, inl.shared_info));
|
||||
pos = inl.position.position;
|
||||
}
|
||||
stack.push_back(pos.Info(cinfo->shared_info()));
|
||||
stack.push_back(SourcePositionInfo(pos, cinfo->shared_info()));
|
||||
return stack;
|
||||
}
|
||||
|
||||
@ -80,12 +67,12 @@ std::vector<SourcePositionInfo> SourcePosition::InliningStack(
|
||||
deopt_data->InliningPositions()->get(pos.InliningId());
|
||||
Handle<SharedFunctionInfo> function(
|
||||
deopt_data->GetInlinedFunction(inl.inlined_function_id));
|
||||
stack.push_back(pos.Info(function));
|
||||
stack.push_back(SourcePositionInfo(pos, function));
|
||||
pos = inl.position;
|
||||
}
|
||||
Handle<SharedFunctionInfo> function(
|
||||
SharedFunctionInfo::cast(deopt_data->SharedFunctionInfo()));
|
||||
stack.push_back(pos.Info(function));
|
||||
stack.push_back(SourcePositionInfo(pos, function));
|
||||
return stack;
|
||||
}
|
||||
|
||||
@ -127,5 +114,17 @@ void SourcePosition::Print(std::ostream& out, Code* code) const {
|
||||
}
|
||||
}
|
||||
|
||||
SourcePositionInfo::SourcePositionInfo(SourcePosition pos,
|
||||
Handle<SharedFunctionInfo> f)
|
||||
: position(pos), function(f) {
|
||||
Handle<Script> script(Script::cast(function->script()));
|
||||
Script::PositionInfo info;
|
||||
if (Script::GetPositionInfo(script, pos.ScriptOffset(), &info,
|
||||
Script::WITH_OFFSET)) {
|
||||
line = info.line;
|
||||
column = info.column;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -43,10 +43,11 @@ class SourcePosition final {
|
||||
}
|
||||
bool isInlined() const { return InliningId() != kNotInlined; }
|
||||
|
||||
// Assumes that the code object is optimized
|
||||
std::vector<SourcePositionInfo> InliningStack(Handle<Code> code) const;
|
||||
std::vector<SourcePositionInfo> InliningStack(CompilationInfo* code) const;
|
||||
std::vector<SourcePositionInfo> InliningStack(CompilationInfo* cinfo) const;
|
||||
|
||||
void Print(std::ostream& out, Code* function) const;
|
||||
void Print(std::ostream& out, Code* code) const;
|
||||
|
||||
int ScriptOffset() const { return ScriptOffsetField::decode(value_) - 1; }
|
||||
int InliningId() const { return InliningIdField::decode(value_) - 1; }
|
||||
@ -75,7 +76,6 @@ class SourcePosition final {
|
||||
|
||||
private:
|
||||
void Print(std::ostream& out, SharedFunctionInfo* function) const;
|
||||
SourcePositionInfo Info(Handle<SharedFunctionInfo> script) const;
|
||||
|
||||
// InliningId is in the high bits for better compression in
|
||||
// SourcePositionTable.
|
||||
@ -102,8 +102,7 @@ struct InliningPosition {
|
||||
};
|
||||
|
||||
struct SourcePositionInfo {
|
||||
explicit SourcePositionInfo(SourcePosition pos, Handle<SharedFunctionInfo> f)
|
||||
: position(pos), function(f) {}
|
||||
SourcePositionInfo(SourcePosition pos, Handle<SharedFunctionInfo> f);
|
||||
|
||||
SourcePosition position;
|
||||
Handle<SharedFunctionInfo> function;
|
||||
|
Loading…
Reference in New Issue
Block a user