Bug 1165904 - Don't call methods on null pointers to fix some -fsanitize=null errors. r=terrence

--HG--
extra : rebase_source : 40b83720b22aa77fec3c1071ca063ad2beb02d99
This commit is contained in:
Jan de Mooij 2015-05-20 15:03:04 +02:00
Родитель 8da3b34de1
Коммит d3c2f28857
3 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -1123,6 +1123,7 @@ inline uintptr_t
ArenaHeader::address() const ArenaHeader::address() const
{ {
uintptr_t addr = reinterpret_cast<uintptr_t>(this); uintptr_t addr = reinterpret_cast<uintptr_t>(this);
MOZ_ASSERT(addr);
MOZ_ASSERT(!(addr & ArenaMask)); MOZ_ASSERT(!(addr & ArenaMask));
MOZ_ASSERT(Chunk::withinArenasRange(addr)); MOZ_ASSERT(Chunk::withinArenasRange(addr));
return addr; return addr;
@ -1186,7 +1187,8 @@ ArenaHeader::setNextDelayedMarking(ArenaHeader* aheader)
MOZ_ASSERT(!(uintptr_t(aheader) & ArenaMask)); MOZ_ASSERT(!(uintptr_t(aheader) & ArenaMask));
MOZ_ASSERT(!auxNextLink && !hasDelayedMarking); MOZ_ASSERT(!auxNextLink && !hasDelayedMarking);
hasDelayedMarking = 1; hasDelayedMarking = 1;
auxNextLink = aheader->arenaAddress() >> ArenaShift; if (aheader)
auxNextLink = aheader->arenaAddress() >> ArenaShift;
} }
inline void inline void
@ -1209,7 +1211,8 @@ ArenaHeader::setNextAllocDuringSweep(ArenaHeader* aheader)
{ {
MOZ_ASSERT(!auxNextLink && !allocatedDuringIncremental); MOZ_ASSERT(!auxNextLink && !allocatedDuringIncremental);
allocatedDuringIncremental = 1; allocatedDuringIncremental = 1;
auxNextLink = aheader->arenaAddress() >> ArenaShift; if (aheader)
auxNextLink = aheader->arenaAddress() >> ArenaShift;
} }
inline void inline void

Просмотреть файл

@ -1948,8 +1948,10 @@ js::TenuringTracer::traceObjectSlots(NativeObject* nobj, uint32_t start, uint32_
HeapSlot* dynStart; HeapSlot* dynStart;
HeapSlot* dynEnd; HeapSlot* dynEnd;
nobj->getSlotRange(start, length, &fixedStart, &fixedEnd, &dynStart, &dynEnd); nobj->getSlotRange(start, length, &fixedStart, &fixedEnd, &dynStart, &dynEnd);
traceSlots(fixedStart->unsafeGet(), fixedEnd->unsafeGet()); if (fixedStart)
traceSlots(dynStart->unsafeGet(), dynEnd->unsafeGet()); traceSlots(fixedStart->unsafeGet(), fixedEnd->unsafeGet());
if (dynStart)
traceSlots(dynStart->unsafeGet(), dynEnd->unsafeGet());
} }
void void

Просмотреть файл

@ -373,13 +373,10 @@ class JitFrameLayout : public CommonFrameLayout
return offsetof(JitFrameLayout, numActualArgs_); return offsetof(JitFrameLayout, numActualArgs_);
} }
static size_t offsetOfThis() { static size_t offsetOfThis() {
JitFrameLayout* base = nullptr; return sizeof(JitFrameLayout);
return reinterpret_cast<size_t>(&base->argv()[0]);
} }
static size_t offsetOfActualArgs() { static size_t offsetOfActualArgs() {
JitFrameLayout* base = nullptr; return offsetOfThis() + sizeof(Value);
// +1 to skip |this|.
return reinterpret_cast<size_t>(&base->argv()[1]);
} }
static size_t offsetOfActualArg(size_t arg) { static size_t offsetOfActualArg(size_t arg) {
return offsetOfActualArgs() + arg * sizeof(Value); return offsetOfActualArgs() + arg * sizeof(Value);