Bug 1057393 - Fix a regression on octane-zlib; r=sfink

--HG--
extra : rebase_source : 3ecf3f741cb5264a426c6edf97ce59184ae6cd34
This commit is contained in:
Terrence Cole 2014-08-25 09:29:51 -07:00
parent 5b1edb6c21
commit ac1f346907
2 changed files with 29 additions and 14 deletions

View File

@ -2769,7 +2769,7 @@ ArenaLists::refillFreeListInGC(Zone *zone, AllocKind thingKind)
Allocator &allocator = zone->allocator;
JS_ASSERT(allocator.arenas.freeLists[thingKind].isEmpty());
JSRuntime *rt = zone->runtimeFromMainThread();
mozilla::DebugOnly<JSRuntime *> rt = zone->runtimeFromMainThread();
JS_ASSERT(rt->isHeapMajorCollecting());
JS_ASSERT(!rt->gc.isBackgroundSweeping());

View File

@ -83,7 +83,7 @@ struct MallocProvider
client()->reportAllocationOverflow();
return nullptr;
}
T *p = (T *)js_pod_malloc<uint8_t>(bytes);
T *p = reinterpret_cast<T *>(js_pod_malloc<uint8_t>(bytes));
if (MOZ_LIKELY(p)) {
client()->updateMallocCounter(bytes);
return p;
@ -104,23 +104,38 @@ struct MallocProvider
}
template <class T>
T *
pod_calloc(size_t numElems) {
T *p = pod_malloc<T>(numElems);
if (MOZ_UNLIKELY(!p))
T *pod_calloc(size_t numElems) {
T *p = js_pod_calloc<T>(numElems);
if (MOZ_LIKELY(p)) {
client()->updateMallocCounter(numElems * sizeof(T));
return p;
}
if (numElems & mozilla::tl::MulOverflowMask<sizeof(T)>::value) {
client()->reportAllocationOverflow();
return nullptr;
memset(p, 0, numElems * sizeof(T));
return p;
}
client()->onOutOfMemory(nullptr, numElems * sizeof(T));
return nullptr;
}
template <class T, class U>
T *
pod_calloc_with_extra(size_t numExtra) {
T *p = pod_malloc_with_extra<T, U>(numExtra);
if (MOZ_UNLIKELY(!p))
T *pod_calloc_with_extra(size_t numExtra) {
if (numExtra & mozilla::tl::MulOverflowMask<sizeof(U)>::value) {
client()->reportAllocationOverflow();
return nullptr;
memset(p, 0, sizeof(T) + numExtra * sizeof(U));
return p;
}
size_t bytes = sizeof(T) + numExtra * sizeof(U);
if (bytes < sizeof(T)) {
client()->reportAllocationOverflow();
return nullptr;
}
T *p = reinterpret_cast<T *>(js_pod_calloc<uint8_t>(bytes));
if (MOZ_LIKELY(p)) {
client()->updateMallocCounter(bytes);
return p;
}
client()->onOutOfMemory(nullptr, bytes);
return nullptr;
}
template <class T>