| Index: src/heap.cc
 | 
| diff --git a/src/heap.cc b/src/heap.cc
 | 
| index 317744e7505fc48e66c5e620b7b1854d7ad2db94..98a2d3374b6949e3ab79d881f00a6d59b4871334 100644
 | 
| --- a/src/heap.cc
 | 
| +++ b/src/heap.cc
 | 
| @@ -293,12 +293,11 @@ GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space) {
 | 
|  
 | 
|  // TODO(1238405): Combine the infrastructure for --heap-stats and
 | 
|  // --log-gc to avoid the complicated preprocessor and flag testing.
 | 
| -#if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
 | 
|  void Heap::ReportStatisticsBeforeGC() {
 | 
|    // Heap::ReportHeapStatistics will also log NewSpace statistics when
 | 
| -  // compiled with ENABLE_LOGGING_AND_PROFILING and --log-gc is set.  The
 | 
| -  // following logic is used to avoid double logging.
 | 
| -#if defined(DEBUG) && defined(ENABLE_LOGGING_AND_PROFILING)
 | 
| +  // compiled --log-gc is set.  The following logic is used to avoid
 | 
| +  // double logging.
 | 
| +#ifdef DEBUG
 | 
|    if (FLAG_heap_stats || FLAG_log_gc) new_space_.CollectStatistics();
 | 
|    if (FLAG_heap_stats) {
 | 
|      ReportHeapStatistics("Before GC");
 | 
| @@ -306,23 +305,16 @@ void Heap::ReportStatisticsBeforeGC() {
 | 
|      new_space_.ReportStatistics();
 | 
|    }
 | 
|    if (FLAG_heap_stats || FLAG_log_gc) new_space_.ClearHistograms();
 | 
| -#elif defined(DEBUG)
 | 
| -  if (FLAG_heap_stats) {
 | 
| -    new_space_.CollectStatistics();
 | 
| -    ReportHeapStatistics("Before GC");
 | 
| -    new_space_.ClearHistograms();
 | 
| -  }
 | 
| -#elif defined(ENABLE_LOGGING_AND_PROFILING)
 | 
| +#else
 | 
|    if (FLAG_log_gc) {
 | 
|      new_space_.CollectStatistics();
 | 
|      new_space_.ReportStatistics();
 | 
|      new_space_.ClearHistograms();
 | 
|    }
 | 
| -#endif
 | 
| +#endif  // DEBUG
 | 
|  }
 | 
|  
 | 
|  
 | 
| -#if defined(ENABLE_LOGGING_AND_PROFILING)
 | 
|  void Heap::PrintShortHeapStatistics() {
 | 
|    if (!FLAG_trace_gc_verbose) return;
 | 
|    PrintF("Memory allocator,   used: %8" V8_PTR_PREFIX "d"
 | 
| @@ -368,7 +360,6 @@ void Heap::PrintShortHeapStatistics() {
 | 
|           lo_space_->Size(),
 | 
|           lo_space_->Available());
 | 
|  }
 | 
| -#endif
 | 
|  
 | 
|  
 | 
|  // TODO(1238405): Combine the infrastructure for --heap-stats and
 | 
| @@ -376,20 +367,17 @@ void Heap::PrintShortHeapStatistics() {
 | 
|  void Heap::ReportStatisticsAfterGC() {
 | 
|    // Similar to the before GC, we use some complicated logic to ensure that
 | 
|    // NewSpace statistics are logged exactly once when --log-gc is turned on.
 | 
| -#if defined(DEBUG) && defined(ENABLE_LOGGING_AND_PROFILING)
 | 
| +#if defined(DEBUG)
 | 
|    if (FLAG_heap_stats) {
 | 
|      new_space_.CollectStatistics();
 | 
|      ReportHeapStatistics("After GC");
 | 
|    } else if (FLAG_log_gc) {
 | 
|      new_space_.ReportStatistics();
 | 
|    }
 | 
| -#elif defined(DEBUG)
 | 
| -  if (FLAG_heap_stats) ReportHeapStatistics("After GC");
 | 
| -#elif defined(ENABLE_LOGGING_AND_PROFILING)
 | 
| +#else
 | 
|    if (FLAG_log_gc) new_space_.ReportStatistics();
 | 
| -#endif
 | 
| +#endif  // DEBUG
 | 
|  }
 | 
| -#endif  // defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
 | 
|  
 | 
|  
 | 
|  void Heap::GarbageCollectionPrologue() {
 | 
| @@ -406,11 +394,11 @@ void Heap::GarbageCollectionPrologue() {
 | 
|    }
 | 
|  
 | 
|    if (FLAG_gc_verbose) Print();
 | 
| -#endif
 | 
| +#endif  // DEBUG
 | 
|  
 | 
| -#if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
 | 
| +#if defined(DEBUG)
 | 
|    ReportStatisticsBeforeGC();
 | 
| -#endif
 | 
| +#endif  // DEBUG
 | 
|  
 | 
|    LiveObjectList::GCPrologue();
 | 
|  }
 | 
| @@ -447,12 +435,10 @@ void Heap::GarbageCollectionEpilogue() {
 | 
|        symbol_table()->Capacity());
 | 
|    isolate_->counters()->number_of_symbols()->Set(
 | 
|        symbol_table()->NumberOfElements());
 | 
| -#if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
 | 
| +#if defined(DEBUG)
 | 
|    ReportStatisticsAfterGC();
 | 
| -#endif
 | 
| -#ifdef ENABLE_DEBUGGER_SUPPORT
 | 
| +#endif  // DEBUG
 | 
|    isolate_->debug()->AfterGarbageCollection();
 | 
| -#endif
 | 
|  }
 | 
|  
 | 
|  
 | 
| @@ -1335,15 +1321,12 @@ class ScavengingVisitor : public StaticVisitorBase {
 | 
|    enum ObjectContents  { DATA_OBJECT, POINTER_OBJECT };
 | 
|    enum SizeRestriction { SMALL, UNKNOWN_SIZE };
 | 
|  
 | 
| -#if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
 | 
|    static void RecordCopiedObject(Heap* heap, HeapObject* obj) {
 | 
|      bool should_record = false;
 | 
|  #ifdef DEBUG
 | 
|      should_record = FLAG_heap_stats;
 | 
|  #endif
 | 
| -#ifdef ENABLE_LOGGING_AND_PROFILING
 | 
|      should_record = should_record || FLAG_log_gc;
 | 
| -#endif
 | 
|      if (should_record) {
 | 
|        if (heap->new_space()->Contains(obj)) {
 | 
|          heap->new_space()->RecordAllocation(obj);
 | 
| @@ -1352,7 +1335,6 @@ class ScavengingVisitor : public StaticVisitorBase {
 | 
|        }
 | 
|      }
 | 
|    }
 | 
| -#endif  // defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
 | 
|  
 | 
|    // Helper function used by CopyObject to copy a source object to an
 | 
|    // allocated target object and update the forwarding pointer in the source
 | 
| @@ -1368,12 +1350,9 @@ class ScavengingVisitor : public StaticVisitorBase {
 | 
|      source->set_map_word(MapWord::FromForwardingAddress(target));
 | 
|  
 | 
|      if (logging_and_profiling_mode == LOGGING_AND_PROFILING_ENABLED) {
 | 
| -#if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
 | 
|        // Update NewSpace stats if necessary.
 | 
|        RecordCopiedObject(heap, target);
 | 
| -#endif
 | 
|        HEAP_PROFILE(heap, ObjectMoveEvent(source->address(), target->address()));
 | 
| -#if defined(ENABLE_LOGGING_AND_PROFILING)
 | 
|        Isolate* isolate = heap->isolate();
 | 
|        if (isolate->logger()->is_logging() ||
 | 
|            CpuProfiler::is_profiling(isolate)) {
 | 
| @@ -1382,7 +1361,6 @@ class ScavengingVisitor : public StaticVisitorBase {
 | 
|                source->address(), target->address()));
 | 
|          }
 | 
|        }
 | 
| -#endif
 | 
|      }
 | 
|  
 | 
|      return target;
 | 
| @@ -1558,7 +1536,6 @@ static void InitializeScavengingVisitorsTables() {
 | 
|  
 | 
|  
 | 
|  void Heap::SwitchScavengingVisitorsTableIfProfilingWasEnabled() {
 | 
| -#ifdef ENABLE_LOGGING_AND_PROFILING
 | 
|    if (scavenging_visitors_table_mode_ == LOGGING_AND_PROFILING_ENABLED) {
 | 
|      // Table was already updated by some isolate.
 | 
|      return;
 | 
| @@ -1584,7 +1561,6 @@ void Heap::SwitchScavengingVisitorsTableIfProfilingWasEnabled() {
 | 
|      Release_Store(&scavenging_visitors_table_mode_,
 | 
|                    LOGGING_AND_PROFILING_ENABLED);
 | 
|    }
 | 
| -#endif
 | 
|  }
 | 
|  
 | 
|  
 | 
| @@ -5908,9 +5884,7 @@ GCTracer::~GCTracer() {
 | 
|      PrintF("\n");
 | 
|    }
 | 
|  
 | 
| -#if defined(ENABLE_LOGGING_AND_PROFILING)
 | 
|    heap_->PrintShortHeapStatistics();
 | 
| -#endif
 | 
|  }
 | 
|  
 | 
|  
 | 
| 
 |