OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 4473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4484 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title, | 4484 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title, |
4485 Handle<Value> security_token) { | 4485 Handle<Value> security_token) { |
4486 IsDeadCheck("v8::CpuProfiler::StopProfiling"); | 4486 IsDeadCheck("v8::CpuProfiler::StopProfiling"); |
4487 return reinterpret_cast<const CpuProfile*>( | 4487 return reinterpret_cast<const CpuProfile*>( |
4488 i::CpuProfiler::StopProfiling( | 4488 i::CpuProfiler::StopProfiling( |
4489 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), | 4489 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), |
4490 *Utils::OpenHandle(*title))); | 4490 *Utils::OpenHandle(*title))); |
4491 } | 4491 } |
4492 | 4492 |
4493 | 4493 |
| 4494 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { |
| 4495 return const_cast<i::HeapGraphEdge*>( |
| 4496 reinterpret_cast<const i::HeapGraphEdge*>(edge)); |
| 4497 } |
| 4498 |
4494 HeapGraphEdge::Type HeapGraphEdge::GetType() const { | 4499 HeapGraphEdge::Type HeapGraphEdge::GetType() const { |
4495 IsDeadCheck("v8::HeapGraphEdge::GetType"); | 4500 IsDeadCheck("v8::HeapGraphEdge::GetType"); |
4496 return static_cast<HeapGraphEdge::Type>( | 4501 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); |
4497 reinterpret_cast<const i::HeapGraphEdge*>(this)->type()); | |
4498 } | 4502 } |
4499 | 4503 |
4500 | 4504 |
4501 Handle<Value> HeapGraphEdge::GetName() const { | 4505 Handle<Value> HeapGraphEdge::GetName() const { |
4502 IsDeadCheck("v8::HeapGraphEdge::GetName"); | 4506 IsDeadCheck("v8::HeapGraphEdge::GetName"); |
4503 const i::HeapGraphEdge* edge = | 4507 i::HeapGraphEdge* edge = ToInternal(this); |
4504 reinterpret_cast<const i::HeapGraphEdge*>(this); | |
4505 switch (edge->type()) { | 4508 switch (edge->type()) { |
4506 case i::HeapGraphEdge::CONTEXT_VARIABLE: | 4509 case i::HeapGraphEdge::kContextVariable: |
4507 case i::HeapGraphEdge::INTERNAL: | 4510 case i::HeapGraphEdge::kInternal: |
4508 case i::HeapGraphEdge::PROPERTY: | 4511 case i::HeapGraphEdge::kProperty: |
4509 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( | 4512 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( |
4510 edge->name()))); | 4513 edge->name()))); |
4511 case i::HeapGraphEdge::ELEMENT: | 4514 case i::HeapGraphEdge::kElement: |
4512 return Handle<Number>(ToApi<Number>(i::Factory::NewNumberFromInt( | 4515 return Handle<Number>(ToApi<Number>(i::Factory::NewNumberFromInt( |
4513 edge->index()))); | 4516 edge->index()))); |
4514 default: UNREACHABLE(); | 4517 default: UNREACHABLE(); |
4515 } | 4518 } |
4516 return ImplementationUtilities::Undefined(); | 4519 return ImplementationUtilities::Undefined(); |
4517 } | 4520 } |
4518 | 4521 |
4519 | 4522 |
4520 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { | 4523 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { |
4521 IsDeadCheck("v8::HeapGraphEdge::GetFromNode"); | 4524 IsDeadCheck("v8::HeapGraphEdge::GetFromNode"); |
4522 const i::HeapEntry* from = | 4525 const i::HeapEntry* from = ToInternal(this)->From(); |
4523 reinterpret_cast<const i::HeapGraphEdge*>(this)->from(); | |
4524 return reinterpret_cast<const HeapGraphNode*>(from); | 4526 return reinterpret_cast<const HeapGraphNode*>(from); |
4525 } | 4527 } |
4526 | 4528 |
4527 | 4529 |
4528 const HeapGraphNode* HeapGraphEdge::GetToNode() const { | 4530 const HeapGraphNode* HeapGraphEdge::GetToNode() const { |
4529 IsDeadCheck("v8::HeapGraphEdge::GetToNode"); | 4531 IsDeadCheck("v8::HeapGraphEdge::GetToNode"); |
4530 const i::HeapEntry* to = | 4532 const i::HeapEntry* to = ToInternal(this)->to(); |
4531 reinterpret_cast<const i::HeapGraphEdge*>(this)->to(); | |
4532 return reinterpret_cast<const HeapGraphNode*>(to); | 4533 return reinterpret_cast<const HeapGraphNode*>(to); |
4533 } | 4534 } |
4534 | 4535 |
4535 | 4536 |
| 4537 static i::HeapGraphPath* ToInternal(const HeapGraphPath* path) { |
| 4538 return const_cast<i::HeapGraphPath*>( |
| 4539 reinterpret_cast<const i::HeapGraphPath*>(path)); |
| 4540 } |
| 4541 |
| 4542 |
4536 int HeapGraphPath::GetEdgesCount() const { | 4543 int HeapGraphPath::GetEdgesCount() const { |
4537 return reinterpret_cast<const i::HeapGraphPath*>(this)->path()->length(); | 4544 return ToInternal(this)->path()->length(); |
4538 } | 4545 } |
4539 | 4546 |
4540 | 4547 |
4541 const HeapGraphEdge* HeapGraphPath::GetEdge(int index) const { | 4548 const HeapGraphEdge* HeapGraphPath::GetEdge(int index) const { |
4542 return reinterpret_cast<const HeapGraphEdge*>( | 4549 return reinterpret_cast<const HeapGraphEdge*>( |
4543 reinterpret_cast<const i::HeapGraphPath*>(this)->path()->at(index)); | 4550 ToInternal(this)->path()->at(index)); |
4544 } | 4551 } |
4545 | 4552 |
4546 | 4553 |
4547 const HeapGraphNode* HeapGraphPath::GetFromNode() const { | 4554 const HeapGraphNode* HeapGraphPath::GetFromNode() const { |
4548 return GetEdgesCount() > 0 ? GetEdge(0)->GetFromNode() : NULL; | 4555 return GetEdgesCount() > 0 ? GetEdge(0)->GetFromNode() : NULL; |
4549 } | 4556 } |
4550 | 4557 |
4551 | 4558 |
4552 const HeapGraphNode* HeapGraphPath::GetToNode() const { | 4559 const HeapGraphNode* HeapGraphPath::GetToNode() const { |
4553 const int count = GetEdgesCount(); | 4560 const int count = GetEdgesCount(); |
4554 return count > 0 ? GetEdge(count - 1)->GetToNode() : NULL; | 4561 return count > 0 ? GetEdge(count - 1)->GetToNode() : NULL; |
4555 } | 4562 } |
4556 | 4563 |
4557 | 4564 |
| 4565 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { |
| 4566 return const_cast<i::HeapEntry*>( |
| 4567 reinterpret_cast<const i::HeapEntry*>(entry)); |
| 4568 } |
| 4569 |
| 4570 |
4558 HeapGraphNode::Type HeapGraphNode::GetType() const { | 4571 HeapGraphNode::Type HeapGraphNode::GetType() const { |
4559 IsDeadCheck("v8::HeapGraphNode::GetType"); | 4572 IsDeadCheck("v8::HeapGraphNode::GetType"); |
4560 return static_cast<HeapGraphNode::Type>( | 4573 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); |
4561 reinterpret_cast<const i::HeapEntry*>(this)->type()); | |
4562 } | 4574 } |
4563 | 4575 |
4564 | 4576 |
4565 Handle<String> HeapGraphNode::GetName() const { | 4577 Handle<String> HeapGraphNode::GetName() const { |
4566 IsDeadCheck("v8::HeapGraphNode::GetName"); | 4578 IsDeadCheck("v8::HeapGraphNode::GetName"); |
4567 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( | 4579 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( |
4568 reinterpret_cast<const i::HeapEntry*>(this)->name()))); | 4580 ToInternal(this)->name()))); |
4569 } | 4581 } |
4570 | 4582 |
4571 | 4583 |
4572 uint64_t HeapGraphNode::GetId() const { | 4584 uint64_t HeapGraphNode::GetId() const { |
4573 IsDeadCheck("v8::HeapGraphNode::GetId"); | 4585 IsDeadCheck("v8::HeapGraphNode::GetId"); |
4574 return reinterpret_cast<const i::HeapEntry*>(this)->id(); | 4586 return ToInternal(this)->id(); |
4575 } | 4587 } |
4576 | 4588 |
4577 | 4589 |
4578 int HeapGraphNode::GetSelfSize() const { | 4590 int HeapGraphNode::GetSelfSize() const { |
4579 IsDeadCheck("v8::HeapGraphNode::GetSelfSize"); | 4591 IsDeadCheck("v8::HeapGraphNode::GetSelfSize"); |
4580 return reinterpret_cast<const i::HeapEntry*>(this)->self_size(); | 4592 return ToInternal(this)->self_size(); |
4581 } | 4593 } |
4582 | 4594 |
4583 | 4595 |
4584 int HeapGraphNode::GetTotalSize() const { | 4596 int HeapGraphNode::GetReachableSize() const { |
4585 IsDeadCheck("v8::HeapSnapshot::GetHead"); | 4597 IsDeadCheck("v8::HeapSnapshot::GetReachableSize"); |
4586 return const_cast<i::HeapEntry*>( | 4598 return ToInternal(this)->ReachableSize(); |
4587 reinterpret_cast<const i::HeapEntry*>(this))->TotalSize(); | |
4588 } | 4599 } |
4589 | 4600 |
4590 | 4601 |
4591 int HeapGraphNode::GetPrivateSize() const { | 4602 int HeapGraphNode::GetRetainedSize() const { |
4592 IsDeadCheck("v8::HeapSnapshot::GetPrivateSize"); | 4603 IsDeadCheck("v8::HeapSnapshot::GetRetainedSize"); |
4593 return const_cast<i::HeapEntry*>( | 4604 return ToInternal(this)->RetainedSize(); |
4594 reinterpret_cast<const i::HeapEntry*>(this))->NonSharedTotalSize(); | |
4595 } | 4605 } |
4596 | 4606 |
4597 | 4607 |
4598 int HeapGraphNode::GetChildrenCount() const { | 4608 int HeapGraphNode::GetChildrenCount() const { |
4599 IsDeadCheck("v8::HeapSnapshot::GetChildrenCount"); | 4609 IsDeadCheck("v8::HeapSnapshot::GetChildrenCount"); |
4600 return reinterpret_cast<const i::HeapEntry*>(this)->children()->length(); | 4610 return ToInternal(this)->children().length(); |
4601 } | 4611 } |
4602 | 4612 |
4603 | 4613 |
4604 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { | 4614 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { |
4605 IsDeadCheck("v8::HeapSnapshot::GetChild"); | 4615 IsDeadCheck("v8::HeapSnapshot::GetChild"); |
4606 return reinterpret_cast<const HeapGraphEdge*>( | 4616 return reinterpret_cast<const HeapGraphEdge*>( |
4607 reinterpret_cast<const i::HeapEntry*>(this)->children()->at(index)); | 4617 &ToInternal(this)->children()[index]); |
4608 } | 4618 } |
4609 | 4619 |
4610 | 4620 |
4611 int HeapGraphNode::GetRetainersCount() const { | 4621 int HeapGraphNode::GetRetainersCount() const { |
4612 IsDeadCheck("v8::HeapSnapshot::GetRetainersCount"); | 4622 IsDeadCheck("v8::HeapSnapshot::GetRetainersCount"); |
4613 return reinterpret_cast<const i::HeapEntry*>(this)->retainers()->length(); | 4623 return ToInternal(this)->retainers().length(); |
4614 } | 4624 } |
4615 | 4625 |
4616 | 4626 |
4617 const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const { | 4627 const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const { |
4618 IsDeadCheck("v8::HeapSnapshot::GetRetainer"); | 4628 IsDeadCheck("v8::HeapSnapshot::GetRetainer"); |
4619 return reinterpret_cast<const HeapGraphEdge*>( | 4629 return reinterpret_cast<const HeapGraphEdge*>( |
4620 reinterpret_cast<const i::HeapEntry*>(this)->retainers()->at(index)); | 4630 ToInternal(this)->retainers()[index]); |
4621 } | 4631 } |
4622 | 4632 |
4623 | 4633 |
4624 int HeapGraphNode::GetRetainingPathsCount() const { | 4634 int HeapGraphNode::GetRetainingPathsCount() const { |
4625 IsDeadCheck("v8::HeapSnapshot::GetRetainingPathsCount"); | 4635 IsDeadCheck("v8::HeapSnapshot::GetRetainingPathsCount"); |
4626 return const_cast<i::HeapEntry*>( | 4636 return ToInternal(this)->GetRetainingPaths()->length(); |
4627 reinterpret_cast<const i::HeapEntry*>( | |
4628 this))->GetRetainingPaths()->length(); | |
4629 } | 4637 } |
4630 | 4638 |
4631 | 4639 |
4632 const HeapGraphPath* HeapGraphNode::GetRetainingPath(int index) const { | 4640 const HeapGraphPath* HeapGraphNode::GetRetainingPath(int index) const { |
4633 IsDeadCheck("v8::HeapSnapshot::GetRetainingPath"); | 4641 IsDeadCheck("v8::HeapSnapshot::GetRetainingPath"); |
4634 return reinterpret_cast<const HeapGraphPath*>( | 4642 return reinterpret_cast<const HeapGraphPath*>( |
4635 const_cast<i::HeapEntry*>( | 4643 ToInternal(this)->GetRetainingPaths()->at(index)); |
4636 reinterpret_cast<const i::HeapEntry*>( | |
4637 this))->GetRetainingPaths()->at(index)); | |
4638 } | 4644 } |
4639 | 4645 |
4640 | 4646 |
4641 const HeapGraphNode* HeapSnapshotsDiff::GetAdditionsRoot() const { | 4647 const HeapGraphNode* HeapSnapshotsDiff::GetAdditionsRoot() const { |
4642 IsDeadCheck("v8::HeapSnapshotsDiff::GetAdditionsRoot"); | 4648 IsDeadCheck("v8::HeapSnapshotsDiff::GetAdditionsRoot"); |
4643 const i::HeapSnapshotsDiff* diff = | 4649 i::HeapSnapshotsDiff* diff = |
4644 reinterpret_cast<const i::HeapSnapshotsDiff*>(this); | 4650 const_cast<i::HeapSnapshotsDiff*>( |
| 4651 reinterpret_cast<const i::HeapSnapshotsDiff*>(this)); |
4645 return reinterpret_cast<const HeapGraphNode*>(diff->additions_root()); | 4652 return reinterpret_cast<const HeapGraphNode*>(diff->additions_root()); |
4646 } | 4653 } |
4647 | 4654 |
4648 | 4655 |
4649 const HeapGraphNode* HeapSnapshotsDiff::GetDeletionsRoot() const { | 4656 const HeapGraphNode* HeapSnapshotsDiff::GetDeletionsRoot() const { |
4650 IsDeadCheck("v8::HeapSnapshotsDiff::GetDeletionsRoot"); | 4657 IsDeadCheck("v8::HeapSnapshotsDiff::GetDeletionsRoot"); |
4651 const i::HeapSnapshotsDiff* diff = | 4658 i::HeapSnapshotsDiff* diff = |
4652 reinterpret_cast<const i::HeapSnapshotsDiff*>(this); | 4659 const_cast<i::HeapSnapshotsDiff*>( |
| 4660 reinterpret_cast<const i::HeapSnapshotsDiff*>(this)); |
4653 return reinterpret_cast<const HeapGraphNode*>(diff->deletions_root()); | 4661 return reinterpret_cast<const HeapGraphNode*>(diff->deletions_root()); |
4654 } | 4662 } |
4655 | 4663 |
4656 | 4664 |
| 4665 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { |
| 4666 return const_cast<i::HeapSnapshot*>( |
| 4667 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); |
| 4668 } |
| 4669 |
| 4670 |
4657 unsigned HeapSnapshot::GetUid() const { | 4671 unsigned HeapSnapshot::GetUid() const { |
4658 IsDeadCheck("v8::HeapSnapshot::GetUid"); | 4672 IsDeadCheck("v8::HeapSnapshot::GetUid"); |
4659 return reinterpret_cast<const i::HeapSnapshot*>(this)->uid(); | 4673 return ToInternal(this)->uid(); |
4660 } | 4674 } |
4661 | 4675 |
4662 | 4676 |
4663 Handle<String> HeapSnapshot::GetTitle() const { | 4677 Handle<String> HeapSnapshot::GetTitle() const { |
4664 IsDeadCheck("v8::HeapSnapshot::GetTitle"); | 4678 IsDeadCheck("v8::HeapSnapshot::GetTitle"); |
4665 const i::HeapSnapshot* snapshot = | |
4666 reinterpret_cast<const i::HeapSnapshot*>(this); | |
4667 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( | 4679 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( |
4668 snapshot->title()))); | 4680 ToInternal(this)->title()))); |
4669 } | 4681 } |
4670 | 4682 |
4671 | 4683 |
4672 const HeapGraphNode* HeapSnapshot::GetRoot() const { | 4684 const HeapGraphNode* HeapSnapshot::GetRoot() const { |
4673 IsDeadCheck("v8::HeapSnapshot::GetHead"); | 4685 IsDeadCheck("v8::HeapSnapshot::GetHead"); |
4674 const i::HeapSnapshot* snapshot = | 4686 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root()); |
4675 reinterpret_cast<const i::HeapSnapshot*>(this); | |
4676 return reinterpret_cast<const HeapGraphNode*>(snapshot->const_root()); | |
4677 } | 4687 } |
4678 | 4688 |
4679 | 4689 |
4680 const HeapSnapshotsDiff* HeapSnapshot::CompareWith( | 4690 const HeapSnapshotsDiff* HeapSnapshot::CompareWith( |
4681 const HeapSnapshot* snapshot) const { | 4691 const HeapSnapshot* snapshot) const { |
4682 IsDeadCheck("v8::HeapSnapshot::CompareWith"); | 4692 IsDeadCheck("v8::HeapSnapshot::CompareWith"); |
4683 i::HeapSnapshot* snapshot1 = const_cast<i::HeapSnapshot*>( | |
4684 reinterpret_cast<const i::HeapSnapshot*>(this)); | |
4685 i::HeapSnapshot* snapshot2 = const_cast<i::HeapSnapshot*>( | |
4686 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); | |
4687 return reinterpret_cast<const HeapSnapshotsDiff*>( | 4693 return reinterpret_cast<const HeapSnapshotsDiff*>( |
4688 snapshot1->CompareWith(snapshot2)); | 4694 ToInternal(this)->CompareWith(ToInternal(snapshot))); |
4689 } | 4695 } |
4690 | 4696 |
4691 | 4697 |
4692 int HeapProfiler::GetSnapshotsCount() { | 4698 int HeapProfiler::GetSnapshotsCount() { |
4693 IsDeadCheck("v8::HeapProfiler::GetSnapshotsCount"); | 4699 IsDeadCheck("v8::HeapProfiler::GetSnapshotsCount"); |
4694 return i::HeapProfiler::GetSnapshotsCount(); | 4700 return i::HeapProfiler::GetSnapshotsCount(); |
4695 } | 4701 } |
4696 | 4702 |
4697 | 4703 |
4698 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) { | 4704 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4794 | 4800 |
4795 | 4801 |
4796 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 4802 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
4797 HandleScopeImplementer* thread_local = | 4803 HandleScopeImplementer* thread_local = |
4798 reinterpret_cast<HandleScopeImplementer*>(storage); | 4804 reinterpret_cast<HandleScopeImplementer*>(storage); |
4799 thread_local->IterateThis(v); | 4805 thread_local->IterateThis(v); |
4800 return storage + ArchiveSpacePerThread(); | 4806 return storage + ArchiveSpacePerThread(); |
4801 } | 4807 } |
4802 | 4808 |
4803 } } // namespace v8::internal | 4809 } } // namespace v8::internal |
OLD | NEW |