| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 static inline int FlagDependentPortOffset() { | 325 static inline int FlagDependentPortOffset() { |
| 326 return ::v8::internal::FLAG_crankshaft == false ? 100 : | 326 return ::v8::internal::FLAG_crankshaft == false ? 100 : |
| 327 ::v8::internal::FLAG_always_opt ? 200 : 0; | 327 ::v8::internal::FLAG_always_opt ? 200 : 0; |
| 328 } | 328 } |
| 329 | 329 |
| 330 | 330 |
| 331 // Helper function that simulates a full new-space in the heap. | 331 // Helper function that simulates a full new-space in the heap. |
| 332 static inline void SimulateFullSpace(v8::internal::NewSpace* space) { | 332 static inline void SimulateFullSpace(v8::internal::NewSpace* space) { |
| 333 int new_linear_size = static_cast<int>( | 333 int new_linear_size = static_cast<int>( |
| 334 *space->allocation_limit_address() - *space->allocation_top_address()); | 334 *space->allocation_limit_address() - *space->allocation_top_address()); |
| 335 if (new_linear_size == 0) return; |
| 335 v8::internal::MaybeObject* maybe = space->AllocateRaw(new_linear_size); | 336 v8::internal::MaybeObject* maybe = space->AllocateRaw(new_linear_size); |
| 336 v8::internal::FreeListNode* node = v8::internal::FreeListNode::cast(maybe); | 337 v8::internal::FreeListNode* node = v8::internal::FreeListNode::cast(maybe); |
| 337 node->set_size(space->heap(), new_linear_size); | 338 node->set_size(space->heap(), new_linear_size); |
| 338 } | 339 } |
| 339 | 340 |
| 340 | 341 |
| 341 // Helper function that simulates a full old-space in the heap. | 342 // Helper function that simulates a full old-space in the heap. |
| 342 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 343 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { |
| 343 int old_linear_size = static_cast<int>(space->limit() - space->top()); | 344 space->EmptyAllocationInfo(); |
| 344 space->Free(space->top(), old_linear_size); | |
| 345 space->SetTop(space->limit(), space->limit()); | |
| 346 space->ResetFreeList(); | 345 space->ResetFreeList(); |
| 347 space->ClearStats(); | 346 space->ClearStats(); |
| 348 } | 347 } |
| 349 | 348 |
| 350 | 349 |
| 351 // Helper class for new allocations tracking and checking. | 350 // Helper class for new allocations tracking and checking. |
| 352 // To use checking of JS allocations tracking in a test, | 351 // To use checking of JS allocations tracking in a test, |
| 353 // just create an instance of this class. | 352 // just create an instance of this class. |
| 354 class HeapObjectsTracker { | 353 class HeapObjectsTracker { |
| 355 public: | 354 public: |
| 356 HeapObjectsTracker() { | 355 HeapObjectsTracker() { |
| 357 heap_profiler_ = i::Isolate::Current()->heap_profiler(); | 356 heap_profiler_ = i::Isolate::Current()->heap_profiler(); |
| 358 CHECK_NE(NULL, heap_profiler_); | 357 CHECK_NE(NULL, heap_profiler_); |
| 359 heap_profiler_->StartHeapAllocationsRecording(); | 358 heap_profiler_->StartHeapAllocationsRecording(); |
| 360 } | 359 } |
| 361 | 360 |
| 362 ~HeapObjectsTracker() { | 361 ~HeapObjectsTracker() { |
| 363 i::Isolate::Current()->heap()->CollectAllAvailableGarbage(); | 362 i::Isolate::Current()->heap()->CollectAllAvailableGarbage(); |
| 364 CHECK_EQ(0, heap_profiler_->FindUntrackedObjects()); | 363 CHECK_EQ(0, heap_profiler_->FindUntrackedObjects()); |
| 365 heap_profiler_->StopHeapAllocationsRecording(); | 364 heap_profiler_->StopHeapAllocationsRecording(); |
| 366 } | 365 } |
| 367 | 366 |
| 368 private: | 367 private: |
| 369 i::HeapProfiler* heap_profiler_; | 368 i::HeapProfiler* heap_profiler_; |
| 370 }; | 369 }; |
| 371 | 370 |
| 372 | 371 |
| 373 #endif // ifndef CCTEST_H_ | 372 #endif // ifndef CCTEST_H_ |
| OLD | NEW |