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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 static inline void DisableDebugger() { v8::Debug::SetDebugEventListener(NULL); } | 595 static inline void DisableDebugger() { v8::Debug::SetDebugEventListener(NULL); } |
596 | 596 |
597 | 597 |
598 static inline void EmptyMessageQueues(v8::Isolate* isolate) { | 598 static inline void EmptyMessageQueues(v8::Isolate* isolate) { |
599 while (v8::platform::PumpMessageLoop(v8::internal::V8::GetCurrentPlatform(), | 599 while (v8::platform::PumpMessageLoop(v8::internal::V8::GetCurrentPlatform(), |
600 isolate)) | 600 isolate)) |
601 ; | 601 ; |
602 } | 602 } |
603 | 603 |
604 | 604 |
605 // Helper class for new allocations tracking and checking. | |
606 // To use checking of JS allocations tracking in a test, | |
607 // just create an instance of this class. | |
608 class HeapObjectsTracker { | |
609 public: | |
610 HeapObjectsTracker() { | |
611 heap_profiler_ = i::Isolate::Current()->heap_profiler(); | |
612 CHECK_NOT_NULL(heap_profiler_); | |
613 heap_profiler_->StartHeapObjectsTracking(true); | |
614 } | |
615 | |
616 ~HeapObjectsTracker() { | |
617 i::Isolate::Current()->heap()->CollectAllAvailableGarbage(); | |
618 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); | |
619 heap_profiler_->StopHeapObjectsTracking(); | |
620 } | |
621 | |
622 private: | |
623 i::HeapProfiler* heap_profiler_; | |
624 }; | |
625 | |
626 | |
627 class InitializedHandleScope { | 605 class InitializedHandleScope { |
628 public: | 606 public: |
629 InitializedHandleScope() | 607 InitializedHandleScope() |
630 : main_isolate_(CcTest::InitIsolateOnce()), | 608 : main_isolate_(CcTest::InitIsolateOnce()), |
631 handle_scope_(main_isolate_) {} | 609 handle_scope_(main_isolate_) {} |
632 | 610 |
633 // Prefixing the below with main_ reduces a lot of naming clashes. | 611 // Prefixing the below with main_ reduces a lot of naming clashes. |
634 i::Isolate* main_isolate() { return main_isolate_; } | 612 i::Isolate* main_isolate() { return main_isolate_; } |
635 | 613 |
636 private: | 614 private: |
637 i::Isolate* main_isolate_; | 615 i::Isolate* main_isolate_; |
638 i::HandleScope handle_scope_; | 616 i::HandleScope handle_scope_; |
639 }; | 617 }; |
640 | 618 |
641 | 619 |
642 class HandleAndZoneScope : public InitializedHandleScope { | 620 class HandleAndZoneScope : public InitializedHandleScope { |
643 public: | 621 public: |
644 HandleAndZoneScope() {} | 622 HandleAndZoneScope() {} |
645 | 623 |
646 // Prefixing the below with main_ reduces a lot of naming clashes. | 624 // Prefixing the below with main_ reduces a lot of naming clashes. |
647 i::Zone* main_zone() { return &main_zone_; } | 625 i::Zone* main_zone() { return &main_zone_; } |
648 | 626 |
649 private: | 627 private: |
650 i::Zone main_zone_; | 628 i::Zone main_zone_; |
651 }; | 629 }; |
652 | 630 |
653 #endif // ifndef CCTEST_H_ | 631 #endif // ifndef CCTEST_H_ |
OLD | NEW |