Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 4fdc95f5ee8a7b27bf01da11f72a6e3a1cd23136..adeced54b5fe1a043ddfee55f92d4a1193ffc565 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -4491,24 +4491,27 @@ const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title, |
} |
+static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { |
+ return const_cast<i::HeapGraphEdge*>( |
+ reinterpret_cast<const i::HeapGraphEdge*>(edge)); |
+} |
+ |
HeapGraphEdge::Type HeapGraphEdge::GetType() const { |
IsDeadCheck("v8::HeapGraphEdge::GetType"); |
- return static_cast<HeapGraphEdge::Type>( |
- reinterpret_cast<const i::HeapGraphEdge*>(this)->type()); |
+ return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); |
} |
Handle<Value> HeapGraphEdge::GetName() const { |
IsDeadCheck("v8::HeapGraphEdge::GetName"); |
- const i::HeapGraphEdge* edge = |
- reinterpret_cast<const i::HeapGraphEdge*>(this); |
+ i::HeapGraphEdge* edge = ToInternal(this); |
switch (edge->type()) { |
- case i::HeapGraphEdge::CONTEXT_VARIABLE: |
- case i::HeapGraphEdge::INTERNAL: |
- case i::HeapGraphEdge::PROPERTY: |
+ case i::HeapGraphEdge::kContextVariable: |
+ case i::HeapGraphEdge::kInternal: |
+ case i::HeapGraphEdge::kProperty: |
return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( |
edge->name()))); |
- case i::HeapGraphEdge::ELEMENT: |
+ case i::HeapGraphEdge::kElement: |
return Handle<Number>(ToApi<Number>(i::Factory::NewNumberFromInt( |
edge->index()))); |
default: UNREACHABLE(); |
@@ -4519,28 +4522,32 @@ Handle<Value> HeapGraphEdge::GetName() const { |
const HeapGraphNode* HeapGraphEdge::GetFromNode() const { |
IsDeadCheck("v8::HeapGraphEdge::GetFromNode"); |
- const i::HeapEntry* from = |
- reinterpret_cast<const i::HeapGraphEdge*>(this)->from(); |
+ const i::HeapEntry* from = ToInternal(this)->From(); |
return reinterpret_cast<const HeapGraphNode*>(from); |
} |
const HeapGraphNode* HeapGraphEdge::GetToNode() const { |
IsDeadCheck("v8::HeapGraphEdge::GetToNode"); |
- const i::HeapEntry* to = |
- reinterpret_cast<const i::HeapGraphEdge*>(this)->to(); |
+ const i::HeapEntry* to = ToInternal(this)->to(); |
return reinterpret_cast<const HeapGraphNode*>(to); |
} |
+static i::HeapGraphPath* ToInternal(const HeapGraphPath* path) { |
+ return const_cast<i::HeapGraphPath*>( |
+ reinterpret_cast<const i::HeapGraphPath*>(path)); |
+} |
+ |
+ |
int HeapGraphPath::GetEdgesCount() const { |
- return reinterpret_cast<const i::HeapGraphPath*>(this)->path()->length(); |
+ return ToInternal(this)->path()->length(); |
} |
const HeapGraphEdge* HeapGraphPath::GetEdge(int index) const { |
return reinterpret_cast<const HeapGraphEdge*>( |
- reinterpret_cast<const i::HeapGraphPath*>(this)->path()->at(index)); |
+ ToInternal(this)->path()->at(index)); |
} |
@@ -4555,137 +4562,136 @@ const HeapGraphNode* HeapGraphPath::GetToNode() const { |
} |
+static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { |
+ return const_cast<i::HeapEntry*>( |
+ reinterpret_cast<const i::HeapEntry*>(entry)); |
+} |
+ |
+ |
HeapGraphNode::Type HeapGraphNode::GetType() const { |
IsDeadCheck("v8::HeapGraphNode::GetType"); |
- return static_cast<HeapGraphNode::Type>( |
- reinterpret_cast<const i::HeapEntry*>(this)->type()); |
+ return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); |
} |
Handle<String> HeapGraphNode::GetName() const { |
IsDeadCheck("v8::HeapGraphNode::GetName"); |
return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( |
- reinterpret_cast<const i::HeapEntry*>(this)->name()))); |
+ ToInternal(this)->name()))); |
} |
uint64_t HeapGraphNode::GetId() const { |
IsDeadCheck("v8::HeapGraphNode::GetId"); |
- return reinterpret_cast<const i::HeapEntry*>(this)->id(); |
+ return ToInternal(this)->id(); |
} |
int HeapGraphNode::GetSelfSize() const { |
IsDeadCheck("v8::HeapGraphNode::GetSelfSize"); |
- return reinterpret_cast<const i::HeapEntry*>(this)->self_size(); |
+ return ToInternal(this)->self_size(); |
} |
-int HeapGraphNode::GetTotalSize() const { |
- IsDeadCheck("v8::HeapSnapshot::GetHead"); |
- return const_cast<i::HeapEntry*>( |
- reinterpret_cast<const i::HeapEntry*>(this))->TotalSize(); |
+int HeapGraphNode::GetReachableSize() const { |
+ IsDeadCheck("v8::HeapSnapshot::GetReachableSize"); |
+ return ToInternal(this)->ReachableSize(); |
} |
-int HeapGraphNode::GetPrivateSize() const { |
- IsDeadCheck("v8::HeapSnapshot::GetPrivateSize"); |
- return const_cast<i::HeapEntry*>( |
- reinterpret_cast<const i::HeapEntry*>(this))->NonSharedTotalSize(); |
+int HeapGraphNode::GetRetainedSize() const { |
+ IsDeadCheck("v8::HeapSnapshot::GetRetainedSize"); |
+ return ToInternal(this)->RetainedSize(); |
} |
int HeapGraphNode::GetChildrenCount() const { |
IsDeadCheck("v8::HeapSnapshot::GetChildrenCount"); |
- return reinterpret_cast<const i::HeapEntry*>(this)->children()->length(); |
+ return ToInternal(this)->children().length(); |
} |
const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { |
IsDeadCheck("v8::HeapSnapshot::GetChild"); |
return reinterpret_cast<const HeapGraphEdge*>( |
- reinterpret_cast<const i::HeapEntry*>(this)->children()->at(index)); |
+ &ToInternal(this)->children()[index]); |
} |
int HeapGraphNode::GetRetainersCount() const { |
IsDeadCheck("v8::HeapSnapshot::GetRetainersCount"); |
- return reinterpret_cast<const i::HeapEntry*>(this)->retainers()->length(); |
+ return ToInternal(this)->retainers().length(); |
} |
const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const { |
IsDeadCheck("v8::HeapSnapshot::GetRetainer"); |
return reinterpret_cast<const HeapGraphEdge*>( |
- reinterpret_cast<const i::HeapEntry*>(this)->retainers()->at(index)); |
+ ToInternal(this)->retainers()[index]); |
} |
int HeapGraphNode::GetRetainingPathsCount() const { |
IsDeadCheck("v8::HeapSnapshot::GetRetainingPathsCount"); |
- return const_cast<i::HeapEntry*>( |
- reinterpret_cast<const i::HeapEntry*>( |
- this))->GetRetainingPaths()->length(); |
+ return ToInternal(this)->GetRetainingPaths()->length(); |
} |
const HeapGraphPath* HeapGraphNode::GetRetainingPath(int index) const { |
IsDeadCheck("v8::HeapSnapshot::GetRetainingPath"); |
return reinterpret_cast<const HeapGraphPath*>( |
- const_cast<i::HeapEntry*>( |
- reinterpret_cast<const i::HeapEntry*>( |
- this))->GetRetainingPaths()->at(index)); |
+ ToInternal(this)->GetRetainingPaths()->at(index)); |
} |
const HeapGraphNode* HeapSnapshotsDiff::GetAdditionsRoot() const { |
IsDeadCheck("v8::HeapSnapshotsDiff::GetAdditionsRoot"); |
- const i::HeapSnapshotsDiff* diff = |
- reinterpret_cast<const i::HeapSnapshotsDiff*>(this); |
+ i::HeapSnapshotsDiff* diff = |
+ const_cast<i::HeapSnapshotsDiff*>( |
+ reinterpret_cast<const i::HeapSnapshotsDiff*>(this)); |
return reinterpret_cast<const HeapGraphNode*>(diff->additions_root()); |
} |
const HeapGraphNode* HeapSnapshotsDiff::GetDeletionsRoot() const { |
IsDeadCheck("v8::HeapSnapshotsDiff::GetDeletionsRoot"); |
- const i::HeapSnapshotsDiff* diff = |
- reinterpret_cast<const i::HeapSnapshotsDiff*>(this); |
+ i::HeapSnapshotsDiff* diff = |
+ const_cast<i::HeapSnapshotsDiff*>( |
+ reinterpret_cast<const i::HeapSnapshotsDiff*>(this)); |
return reinterpret_cast<const HeapGraphNode*>(diff->deletions_root()); |
} |
+static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { |
+ return const_cast<i::HeapSnapshot*>( |
+ reinterpret_cast<const i::HeapSnapshot*>(snapshot)); |
+} |
+ |
+ |
unsigned HeapSnapshot::GetUid() const { |
IsDeadCheck("v8::HeapSnapshot::GetUid"); |
- return reinterpret_cast<const i::HeapSnapshot*>(this)->uid(); |
+ return ToInternal(this)->uid(); |
} |
Handle<String> HeapSnapshot::GetTitle() const { |
IsDeadCheck("v8::HeapSnapshot::GetTitle"); |
- const i::HeapSnapshot* snapshot = |
- reinterpret_cast<const i::HeapSnapshot*>(this); |
return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( |
- snapshot->title()))); |
+ ToInternal(this)->title()))); |
} |
const HeapGraphNode* HeapSnapshot::GetRoot() const { |
IsDeadCheck("v8::HeapSnapshot::GetHead"); |
- const i::HeapSnapshot* snapshot = |
- reinterpret_cast<const i::HeapSnapshot*>(this); |
- return reinterpret_cast<const HeapGraphNode*>(snapshot->const_root()); |
+ return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root()); |
} |
const HeapSnapshotsDiff* HeapSnapshot::CompareWith( |
const HeapSnapshot* snapshot) const { |
IsDeadCheck("v8::HeapSnapshot::CompareWith"); |
- i::HeapSnapshot* snapshot1 = const_cast<i::HeapSnapshot*>( |
- reinterpret_cast<const i::HeapSnapshot*>(this)); |
- i::HeapSnapshot* snapshot2 = const_cast<i::HeapSnapshot*>( |
- reinterpret_cast<const i::HeapSnapshot*>(snapshot)); |
return reinterpret_cast<const HeapSnapshotsDiff*>( |
- snapshot1->CompareWith(snapshot2)); |
+ ToInternal(this)->CompareWith(ToInternal(snapshot))); |
} |