2010-12-15 08:07:27 +00:00
|
|
|
// Copyright 2009-2010 the V8 project authors. All rights reserved.
|
2009-09-16 13:41:24 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#ifndef V8_HEAP_PROFILER_H_
|
|
|
|
#define V8_HEAP_PROFILER_H_
|
|
|
|
|
2013-07-04 16:32:12 +00:00
|
|
|
#include "heap-snapshot-generator-inl.h"
|
2011-03-18 20:35:07 +00:00
|
|
|
#include "isolate.h"
|
2013-12-03 09:48:30 +00:00
|
|
|
#include "smart-pointers.h"
|
2010-03-09 06:38:33 +00:00
|
|
|
|
2009-09-16 13:41:24 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2010-06-15 11:44:07 +00:00
|
|
|
class HeapSnapshot;
|
|
|
|
|
2009-09-16 13:41:24 +00:00
|
|
|
class HeapProfiler {
|
|
|
|
public:
|
2013-04-02 08:03:01 +00:00
|
|
|
explicit HeapProfiler(Heap* heap);
|
|
|
|
~HeapProfiler();
|
2010-06-16 19:53:24 +00:00
|
|
|
|
2013-04-02 08:03:01 +00:00
|
|
|
size_t GetMemorySizeUsedByProfiler();
|
2012-06-13 11:02:24 +00:00
|
|
|
|
2013-04-02 08:03:01 +00:00
|
|
|
HeapSnapshot* TakeSnapshot(
|
2012-12-04 17:17:55 +00:00
|
|
|
const char* name,
|
|
|
|
v8::ActivityControl* control,
|
|
|
|
v8::HeapProfiler::ObjectNameResolver* resolver);
|
2013-04-02 08:03:01 +00:00
|
|
|
HeapSnapshot* TakeSnapshot(
|
2012-12-04 17:17:55 +00:00
|
|
|
String* name,
|
|
|
|
v8::ActivityControl* control,
|
|
|
|
v8::HeapProfiler::ObjectNameResolver* resolver);
|
2012-04-13 08:52:25 +00:00
|
|
|
|
2013-12-02 14:27:24 +00:00
|
|
|
void StartHeapObjectsTracking(bool track_allocations);
|
2013-04-02 08:03:01 +00:00
|
|
|
void StopHeapObjectsTracking();
|
2013-12-03 09:48:30 +00:00
|
|
|
AllocationTracker* allocation_tracker() { return *allocation_tracker_; }
|
|
|
|
HeapObjectsMap* heap_object_map() { return *ids_; }
|
|
|
|
StringsStorage* names() { return *names_; }
|
2013-10-14 12:41:28 +00:00
|
|
|
|
2013-04-02 08:03:01 +00:00
|
|
|
SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
|
|
|
|
int GetSnapshotsCount();
|
|
|
|
HeapSnapshot* GetSnapshot(int index);
|
|
|
|
SnapshotObjectId GetSnapshotObjectId(Handle<Object> obj);
|
|
|
|
void DeleteAllSnapshots();
|
2013-12-03 09:48:30 +00:00
|
|
|
void RemoveSnapshot(HeapSnapshot* snapshot);
|
2010-06-15 11:44:07 +00:00
|
|
|
|
2013-10-14 12:41:28 +00:00
|
|
|
void ObjectMoveEvent(Address from, Address to, int size);
|
|
|
|
|
2013-11-29 09:54:38 +00:00
|
|
|
void AllocationEvent(Address addr, int size);
|
2013-10-14 12:41:28 +00:00
|
|
|
|
|
|
|
void UpdateObjectSizeEvent(Address addr, int size);
|
2010-07-15 13:21:50 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
void DefineWrapperClass(
|
2011-03-10 12:05:31 +00:00
|
|
|
uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback);
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id,
|
|
|
|
Object** wrapper);
|
2013-04-24 15:59:23 +00:00
|
|
|
void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info);
|
|
|
|
|
2013-11-29 09:47:32 +00:00
|
|
|
bool is_tracking_object_moves() const { return is_tracking_object_moves_; }
|
2013-12-03 09:48:30 +00:00
|
|
|
bool is_tracking_allocations() { return !allocation_tracker_.is_empty(); }
|
2013-10-14 12:41:28 +00:00
|
|
|
|
2013-12-03 09:48:30 +00:00
|
|
|
Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
|
2013-10-14 12:41:28 +00:00
|
|
|
|
2009-09-16 13:41:24 +00:00
|
|
|
private:
|
2013-12-03 09:48:30 +00:00
|
|
|
Heap* heap() const { return ids_->heap(); }
|
2013-02-11 13:02:20 +00:00
|
|
|
|
2013-12-03 09:48:30 +00:00
|
|
|
// Mapping from HeapObject addresses to objects' uids.
|
|
|
|
SmartPointer<HeapObjectsMap> ids_;
|
|
|
|
List<HeapSnapshot*> snapshots_;
|
|
|
|
SmartPointer<StringsStorage> names_;
|
2010-06-15 11:44:07 +00:00
|
|
|
unsigned next_snapshot_uid_;
|
2011-03-10 12:05:31 +00:00
|
|
|
List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_;
|
2013-12-03 09:48:30 +00:00
|
|
|
SmartPointer<AllocationTracker> allocation_tracker_;
|
2013-11-29 09:47:32 +00:00
|
|
|
bool is_tracking_object_moves_;
|
2009-09-16 13:41:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_HEAP_PROFILER_H_
|