mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 670772 - JSCodeGenerator::upvarMap should use exactly as much space as it needs. (r=njn)
--HG-- extra : rebase_source : 40b9a070023da205817e275e936e8a1acbe38c2b
This commit is contained in:
parent
ea5644dbe3
commit
1ae6b9e3c0
@ -2315,8 +2315,19 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
size_t lexdepCount = cg->roLexdeps->count();
|
||||
|
||||
JS_ASSERT_IF(!upvarMap.empty(), lexdepCount == upvarMap.length());
|
||||
if (upvarMap.empty() && !upvarMap.appendN(UpvarCookie(), lexdepCount))
|
||||
return JS_FALSE;
|
||||
if (upvarMap.empty()) {
|
||||
/* Lazily initialize the upvar map with exactly the necessary capacity. */
|
||||
if (lexdepCount <= upvarMap.sMaxInlineStorage) {
|
||||
JS_ALWAYS_TRUE(upvarMap.growByUninitialized(lexdepCount));
|
||||
} else {
|
||||
void *buf = upvarMap.allocPolicy().malloc_(lexdepCount * sizeof(UpvarCookie));
|
||||
if (!buf)
|
||||
return JS_FALSE;
|
||||
upvarMap.replaceRawBuffer(static_cast<UpvarCookie *>(buf), lexdepCount);
|
||||
}
|
||||
for (size_t i = 0; i < lexdepCount; ++i)
|
||||
upvarMap[i] = UpvarCookie();
|
||||
}
|
||||
|
||||
uintN slot = cookie.slot();
|
||||
if (slot != UpvarCookie::CALLEE_SLOT && dn_kind != JSDefinition::ARG) {
|
||||
|
@ -196,7 +196,7 @@ class DefnOrHeader;
|
||||
typedef InlineMap<JSAtom *, JSDefinition *, 24> AtomDefnMap;
|
||||
typedef InlineMap<JSAtom *, jsatomid, 24> AtomIndexMap;
|
||||
typedef InlineMap<JSAtom *, DefnOrHeader, 24> AtomDOHMap;
|
||||
typedef Vector<UpvarCookie> UpvarCookies;
|
||||
typedef Vector<UpvarCookie, 8> UpvarCookies;
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
|
@ -306,6 +306,10 @@ class Vector : private AllocPolicy
|
||||
return *this;
|
||||
}
|
||||
|
||||
AllocPolicy &allocPolicy() {
|
||||
return *this;
|
||||
}
|
||||
|
||||
enum { InlineLength = N };
|
||||
|
||||
size_t length() const {
|
||||
|
Loading…
Reference in New Issue
Block a user