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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // Helper function that simulates a full old-space in the heap. | 337 // Helper function that simulates a full old-space in the heap. |
338 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 338 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { |
339 int old_linear_size = static_cast<int>(space->limit() - space->top()); | 339 int old_linear_size = static_cast<int>(space->limit() - space->top()); |
340 space->Free(space->top(), old_linear_size); | 340 space->Free(space->top(), old_linear_size); |
341 space->SetTop(space->limit(), space->limit()); | 341 space->SetTop(space->limit(), space->limit()); |
342 space->ResetFreeList(); | 342 space->ResetFreeList(); |
343 space->ClearStats(); | 343 space->ClearStats(); |
344 } | 344 } |
345 | 345 |
346 | 346 |
| 347 // Helper class for new allocations tracking and checking. |
| 348 // To use checking of JS allocations tracking in a test, |
| 349 // just create an instance of this class. |
| 350 class HeapObjectsTracker { |
| 351 public: |
| 352 HeapObjectsTracker() { |
| 353 heap_profiler_ = i::Isolate::Current()->heap_profiler(); |
| 354 CHECK_NE(NULL, heap_profiler_); |
| 355 heap_profiler_->StartHeapAllocationsRecording(); |
| 356 } |
| 357 |
| 358 ~HeapObjectsTracker() { |
| 359 i::Isolate::Current()->heap()->CollectAllAvailableGarbage(); |
| 360 CHECK_EQ(0, heap_profiler_->FindUntrackedObjects()); |
| 361 heap_profiler_->StopHeapAllocationsRecording(); |
| 362 } |
| 363 |
| 364 private: |
| 365 i::HeapProfiler* heap_profiler_; |
| 366 }; |
| 367 |
| 368 |
347 #endif // ifndef CCTEST_H_ | 369 #endif // ifndef CCTEST_H_ |
OLD | NEW |