Permalink
Browse files

Make locals smaller in the repo

Summary:
- The Indexed map for locals are name => id and id => name.
- In the current repo we store every name twice.

Reviewed By: markw65

Differential Revision: D13090465

fbshipit-source-id: 27e3c0673c6755752439085492d54bf20338bf46
  • Loading branch information...
WizKid authored and hhvm-bot committed Nov 26, 2018
1 parent 098ea64 commit 417fd81c41d187a06fc11e5fd23f9eaa4d0034d0
Showing with 23 additions and 1 deletion.
  1. +4 −1 hphp/runtime/vm/func-emitter.cpp
  2. +19 −0 hphp/runtime/vm/indexed-string-map.h
@@ -566,10 +566,12 @@ void FuncEmitter::serdeMetaData(SerDe& sd) {
// NOTE: name, top, and a few other fields currently handled outside of this.
Offset past_delta;
Attr a = attrs;
std::vector<LowStringPtr> localNames;
if (!SerDe::deserializing) {
past_delta = past - base;
a = fix_attrs(attrs);
localNames = m_localNames.list();
}
sd(line1)
@@ -588,7 +590,7 @@ void FuncEmitter::serdeMetaData(SerDe& sd) {
(m_repoBoolBitset)
(params)
(m_localNames)
(localNames)
(staticVars)
(ehtab)
(fpitab)
@@ -603,6 +605,7 @@ void FuncEmitter::serdeMetaData(SerDe& sd) {
repoAwaitedReturnType.resolveArray(ue());
past = base + past_delta;
attrs = fix_attrs(a);
m_localNames.fromList(std::move(localNames));
}
}
@@ -251,6 +251,25 @@ struct IndexedStringMap<T,CaseSensitive,Index,InvalidIndex>::Builder {
}
}
const std::vector<T>& list() const {
return m_list;
}
void fromList(const std::vector<T>&& list) {
assertx(
!size() && "IndexedStringMap::Builder::fromList called more than once"
);
m_list = std::move(list);
for (Offset i = 0; i < list.size(); ++i) {
if (!m_map.emplace(list[i], i).second) {
always_assert(
false && "IndexedStringMap::Builder::fromList key already exists"
);
}
}
}
private:
friend struct IndexedStringMap;
std::vector<T> m_list;

0 comments on commit 417fd81

Please sign in to comment.