Skip to content

Commit

Permalink
Directly restore line table from repo to unit
Browse files Browse the repository at this point in the history
The line table is a shorter version of the source location table and is needed for run time behavior beyond on-line debugging. When a unit is read from a repo, the line table is converted to a pseudo source location table, which is then converted back to a line table when the unit emitter creates the unit. This line table to source location table to line table conversion seems silly in itself. It also does not round trip faithfully, with the result that code that depends on the line table will behave differently the first time than the second time. This may have be the source of flaky tests in the past. Right now, the debugger's small step flow test fails if run a second time.

This diff gets rid of the conversion and directly propagates the line table from the repo to the unit.

Reviewed By: @mikemag

Differential Revision: D969062
  • Loading branch information
Herman Venter authored and sgolemon committed Sep 17, 2013
1 parent 147b983 commit 55ca52b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
16 changes: 6 additions & 10 deletions hphp/runtime/vm/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2253,15 +2253,7 @@ void UnitEmitter::setBcMeta(const uchar* bc_meta, size_t bc_meta_len) {
}

void UnitEmitter::setLines(const LineTable& lines) {
Offset prevPastOffset = 0;
for (size_t i = 0; i < lines.size(); ++i) {
const LineEntry* line = &lines[i];
Location sLoc;
sLoc.line0 = sLoc.line1 = line->val();
Offset pastOffset = line->pastOffset();
recordSourceLocation(&sLoc, prevPastOffset);
prevPastOffset = pastOffset;
}
this->m_lineTable = lines;
}

Id UnitEmitter::mergeLitstr(const StringData* litstr) {
Expand Down Expand Up @@ -2656,7 +2648,11 @@ Unit* UnitEmitter::create() {
}
assert(ix == mi->m_mergeablesSize);
mi->mergeableObj(ix) = (void*)UnitMergeKindDone;
u->m_lineTable = createLineTable(m_sourceLocTab, m_bclen);
if (m_lineTable.size() == 0) {
u->m_lineTable = createLineTable(m_sourceLocTab, m_bclen);
} else {
u->m_lineTable = m_lineTable;
}
for (size_t i = 0; i < m_feTab.size(); ++i) {
assert(m_feTab[i].second->past() == m_feTab[i].first);
assert(m_fMap.find(m_feTab[i].second) != m_fMap.end());
Expand Down
1 change: 1 addition & 0 deletions hphp/runtime/vm/unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,7 @@ class UnitEmitter {
*/
std::vector<std::pair<Offset,SourceLoc> > m_sourceLocTab;
std::vector<std::pair<Offset,const FuncEmitter*> > m_feTab;
LineTable m_lineTable;
std::vector<Typedef> m_typedefs;
};

Expand Down

0 comments on commit 55ca52b

Please sign in to comment.