| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // Helper function that simulates a full old-space in the heap. | 293 // Helper function that simulates a full old-space in the heap. |
| 294 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 294 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { |
| 295 int old_linear_size = static_cast<int>(space->limit() - space->top()); | 295 int old_linear_size = static_cast<int>(space->limit() - space->top()); |
| 296 space->Free(space->top(), old_linear_size); | 296 space->Free(space->top(), old_linear_size); |
| 297 space->SetTop(space->limit(), space->limit()); | 297 space->SetTop(space->limit(), space->limit()); |
| 298 space->ResetFreeList(); | 298 space->ResetFreeList(); |
| 299 space->ClearStats(); | 299 space->ClearStats(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 | 302 |
| 303 // Helper class for new allocations tracking and checking |
| 304 class HeapObjectsTracker { |
| 305 public: |
| 306 HeapObjectsTracker() { |
| 307 heap_profiler_ = i::Isolate::Current()->heap_profiler(); |
| 308 CHECK_NE(NULL, heap_profiler_); |
| 309 |
| 310 heap_profiler_->StartHeapObjectsTracking(); |
| 311 |
| 312 HEAP->CollectAllAvailableGarbage(); |
| 313 HEAP->CollectAllAvailableGarbage(); |
| 314 HEAP->CollectAllAvailableGarbage(); |
| 315 untracked_on_start_ = heap_profiler_->CheckAllocationsTracking(); |
| 316 } |
| 317 |
| 318 virtual ~HeapObjectsTracker() { |
| 319 CHECK_GE(0, test()); |
| 320 heap_profiler_->StopHeapObjectsTracking(); |
| 321 } |
| 322 |
| 323 int test() { |
| 324 HEAP->CollectAllAvailableGarbage(); |
| 325 HEAP->CollectAllAvailableGarbage(); |
| 326 HEAP->CollectAllAvailableGarbage(); |
| 327 |
| 328 return heap_profiler_->CheckAllocationsTracking() - untracked_on_start_; |
| 329 } |
| 330 |
| 331 private: |
| 332 i::HeapProfiler* heap_profiler_; |
| 333 int untracked_on_start_; |
| 334 }; |
| 335 |
| 336 |
| 303 #endif // ifndef CCTEST_H_ | 337 #endif // ifndef CCTEST_H_ |
| OLD | NEW |