Work around a bug in Clang that optimizes away a NULL check

Review URL: https://codereview.chromium.org/12090072

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13562 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 46bc919b
...@@ -711,7 +711,7 @@ LargePage* MemoryAllocator::AllocateLargePage(intptr_t object_size, ...@@ -711,7 +711,7 @@ LargePage* MemoryAllocator::AllocateLargePage(intptr_t object_size,
void MemoryAllocator::Free(MemoryChunk* chunk) { void MemoryAllocator::Free(MemoryChunk* chunk) {
LOG(isolate_, DeleteEvent("MemoryChunk", chunk)); LOG(isolate_, DeleteEvent("MemoryChunk", chunk));
if (chunk->owner() != NULL) { if (chunk->has_owner()) {
ObjectSpace space = ObjectSpace space =
static_cast<ObjectSpace>(1 << chunk->owner()->identity()); static_cast<ObjectSpace>(1 << chunk->owner()->identity());
PerformAllocationCallback(space, kAllocationActionFree, chunk->size()); PerformAllocationCallback(space, kAllocationActionFree, chunk->size());
......
...@@ -333,6 +333,14 @@ class MemoryChunk { ...@@ -333,6 +333,14 @@ class MemoryChunk {
kFailureTag); kFailureTag);
} }
// Workaround for a bug in Clang-3.3 which in some situations optimizes away
// an "if (chunk->owner() != NULL)" check.
bool has_owner() {
if (owner_ == 0) return false;
if (reinterpret_cast<intptr_t>(owner_) == kFailureTag) return false;
return true;
}
VirtualMemory* reserved_memory() { VirtualMemory* reserved_memory() {
return &reservation_; return &reservation_;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment