Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: src/api.cc

Issue 2822009: Heap profiler: publish API and add test. (Closed)
Patch Set: comments addressed Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8-profiler.h ('k') | src/heap-profiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "api.h" 30 #include "api.h"
31 #include "arguments.h" 31 #include "arguments.h"
32 #include "bootstrapper.h" 32 #include "bootstrapper.h"
33 #include "compiler.h" 33 #include "compiler.h"
34 #include "debug.h" 34 #include "debug.h"
35 #include "execution.h" 35 #include "execution.h"
36 #include "global-handles.h" 36 #include "global-handles.h"
37 #include "heap-profiler.h"
37 #include "messages.h" 38 #include "messages.h"
38 #include "platform.h" 39 #include "platform.h"
39 #include "profile-generator-inl.h" 40 #include "profile-generator-inl.h"
40 #include "serialize.h" 41 #include "serialize.h"
41 #include "snapshot.h" 42 #include "snapshot.h"
42 #include "top.h" 43 #include "top.h"
43 #include "utils.h" 44 #include "utils.h"
44 #include "v8threads.h" 45 #include "v8threads.h"
45 #include "version.h" 46 #include "version.h"
46 47
(...skipping 4392 matching lines...) Expand 10 before | Expand all | Expand 10 after
4439 4440
4440 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title, 4441 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title,
4441 Handle<Value> security_token) { 4442 Handle<Value> security_token) {
4442 IsDeadCheck("v8::CpuProfiler::StopProfiling"); 4443 IsDeadCheck("v8::CpuProfiler::StopProfiling");
4443 return reinterpret_cast<const CpuProfile*>( 4444 return reinterpret_cast<const CpuProfile*>(
4444 i::CpuProfiler::StopProfiling( 4445 i::CpuProfiler::StopProfiling(
4445 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 4446 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
4446 *Utils::OpenHandle(*title))); 4447 *Utils::OpenHandle(*title)));
4447 } 4448 }
4448 4449
4450
4451 HeapGraphEdge::Type HeapGraphEdge::GetType() const {
4452 IsDeadCheck("v8::HeapGraphEdge::GetType");
4453 return static_cast<HeapGraphEdge::Type>(
4454 reinterpret_cast<const i::HeapGraphEdge*>(this)->type());
4455 }
4456
4457
4458 Handle<Value> HeapGraphEdge::GetName() const {
4459 IsDeadCheck("v8::HeapGraphEdge::GetName");
4460 const i::HeapGraphEdge* edge =
4461 reinterpret_cast<const i::HeapGraphEdge*>(this);
4462 switch (edge->type()) {
4463 case i::HeapGraphEdge::CONTEXT_VARIABLE:
4464 case i::HeapGraphEdge::PROPERTY:
4465 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol(
4466 edge->name())));
4467 case i::HeapGraphEdge::ELEMENT:
4468 return Handle<Number>(ToApi<Number>(i::Factory::NewNumberFromInt(
4469 edge->index())));
4470 default: UNREACHABLE();
4471 }
4472 return ImplementationUtilities::Undefined();
4473 }
4474
4475
4476 const HeapGraphNode* HeapGraphEdge::GetFromNode() const {
4477 IsDeadCheck("v8::HeapGraphEdge::GetFromNode");
4478 const i::HeapEntry* from =
4479 reinterpret_cast<const i::HeapGraphEdge*>(this)->from();
4480 return reinterpret_cast<const HeapGraphNode*>(from);
4481 }
4482
4483
4484 const HeapGraphNode* HeapGraphEdge::GetToNode() const {
4485 IsDeadCheck("v8::HeapGraphEdge::GetToNode");
4486 const i::HeapEntry* to =
4487 reinterpret_cast<const i::HeapGraphEdge*>(this)->to();
4488 return reinterpret_cast<const HeapGraphNode*>(to);
4489 }
4490
4491
4492 int HeapGraphPath::GetEdgesCount() const {
4493 return reinterpret_cast<const i::HeapGraphPath*>(this)->path()->length();
4494 }
4495
4496
4497 const HeapGraphEdge* HeapGraphPath::GetEdge(int index) const {
4498 return reinterpret_cast<const HeapGraphEdge*>(
4499 reinterpret_cast<const i::HeapGraphPath*>(this)->path()->at(index));
4500 }
4501
4502
4503 const HeapGraphNode* HeapGraphPath::GetFromNode() const {
4504 return GetEdgesCount() > 0 ? GetEdge(0)->GetFromNode() : NULL;
4505 }
4506
4507
4508 const HeapGraphNode* HeapGraphPath::GetToNode() const {
4509 const int count = GetEdgesCount();
4510 return count > 0 ? GetEdge(count - 1)->GetToNode() : NULL;
4511 }
4512
4513
4514 HeapGraphNode::Type HeapGraphNode::GetType() const {
4515 IsDeadCheck("v8::HeapGraphNode::GetType");
4516 return static_cast<HeapGraphNode::Type>(
4517 reinterpret_cast<const i::HeapEntry*>(this)->type());
4518 }
4519
4520
4521 Handle<String> HeapGraphNode::GetName() const {
4522 IsDeadCheck("v8::HeapGraphNode::GetName");
4523 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol(
4524 reinterpret_cast<const i::HeapEntry*>(this)->name())));
4525 }
4526
4527
4528 int HeapGraphNode::GetSelfSize() const {
4529 IsDeadCheck("v8::HeapGraphNode::GetSelfSize");
4530 return reinterpret_cast<const i::HeapEntry*>(this)->self_size();
4531 }
4532
4533
4534 int HeapGraphNode::GetTotalSize() const {
4535 IsDeadCheck("v8::HeapSnapshot::GetHead");
4536 return const_cast<i::HeapEntry*>(
4537 reinterpret_cast<const i::HeapEntry*>(this))->TotalSize();
4538 }
4539
4540
4541 int HeapGraphNode::GetPrivateSize() const {
4542 IsDeadCheck("v8::HeapSnapshot::GetPrivateSize");
4543 return const_cast<i::HeapEntry*>(
4544 reinterpret_cast<const i::HeapEntry*>(this))->NonSharedTotalSize();
4545 }
4546
4547
4548 int HeapGraphNode::GetChildrenCount() const {
4549 IsDeadCheck("v8::HeapSnapshot::GetChildrenCount");
4550 return reinterpret_cast<const i::HeapEntry*>(this)->children()->length();
4551 }
4552
4553
4554 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const {
4555 IsDeadCheck("v8::HeapSnapshot::GetChild");
4556 return reinterpret_cast<const HeapGraphEdge*>(
4557 reinterpret_cast<const i::HeapEntry*>(this)->children()->at(index));
4558 }
4559
4560
4561 int HeapGraphNode::GetRetainersCount() const {
4562 IsDeadCheck("v8::HeapSnapshot::GetRetainersCount");
4563 return reinterpret_cast<const i::HeapEntry*>(this)->retainers()->length();
4564 }
4565
4566
4567 const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const {
4568 IsDeadCheck("v8::HeapSnapshot::GetRetainer");
4569 return reinterpret_cast<const HeapGraphEdge*>(
4570 reinterpret_cast<const i::HeapEntry*>(this)->retainers()->at(index));
4571 }
4572
4573
4574 int HeapGraphNode::GetRetainingPathsCount() const {
4575 IsDeadCheck("v8::HeapSnapshot::GetRetainingPathsCount");
4576 return const_cast<i::HeapEntry*>(
4577 reinterpret_cast<const i::HeapEntry*>(
4578 this))->GetRetainingPaths()->length();
4579 }
4580
4581
4582 const HeapGraphPath* HeapGraphNode::GetRetainingPath(int index) const {
4583 IsDeadCheck("v8::HeapSnapshot::GetRetainingPath");
4584 return reinterpret_cast<const HeapGraphPath*>(
4585 const_cast<i::HeapEntry*>(
4586 reinterpret_cast<const i::HeapEntry*>(
4587 this))->GetRetainingPaths()->at(index));
4588 }
4589
4590
4591 unsigned HeapSnapshot::GetUid() const {
4592 IsDeadCheck("v8::HeapSnapshot::GetUid");
4593 return reinterpret_cast<const i::HeapSnapshot*>(this)->uid();
4594 }
4595
4596
4597 Handle<String> HeapSnapshot::GetTitle() const {
4598 IsDeadCheck("v8::HeapSnapshot::GetTitle");
4599 const i::HeapSnapshot* snapshot =
4600 reinterpret_cast<const i::HeapSnapshot*>(this);
4601 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol(
4602 snapshot->title())));
4603 }
4604
4605
4606 const HeapGraphNode* HeapSnapshot::GetHead() const {
4607 IsDeadCheck("v8::HeapSnapshot::GetHead");
4608 const i::HeapSnapshot* snapshot =
4609 reinterpret_cast<const i::HeapSnapshot*>(this);
4610 return reinterpret_cast<const HeapGraphNode*>(snapshot->const_root());
4611 }
4612
4613
4614 int HeapProfiler::GetSnapshotsCount() {
4615 IsDeadCheck("v8::HeapProfiler::GetSnapshotsCount");
4616 return i::HeapProfiler::GetSnapshotsCount();
4617 }
4618
4619
4620 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) {
4621 IsDeadCheck("v8::HeapProfiler::GetSnapshot");
4622 return reinterpret_cast<const HeapSnapshot*>(
4623 i::HeapProfiler::GetSnapshot(index));
4624 }
4625
4626
4627 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {
4628 IsDeadCheck("v8::HeapProfiler::FindSnapshot");
4629 return reinterpret_cast<const HeapSnapshot*>(
4630 i::HeapProfiler::FindSnapshot(uid));
4631 }
4632
4633
4634 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title) {
4635 IsDeadCheck("v8::HeapProfiler::TakeSnapshot");
4636 return reinterpret_cast<const HeapSnapshot*>(
4637 i::HeapProfiler::TakeSnapshot(*Utils::OpenHandle(*title)));
4638 }
4639
4449 #endif // ENABLE_LOGGING_AND_PROFILING 4640 #endif // ENABLE_LOGGING_AND_PROFILING
4450 4641
4451 4642
4452 namespace internal { 4643 namespace internal {
4453 4644
4454 4645
4455 HandleScopeImplementer* HandleScopeImplementer::instance() { 4646 HandleScopeImplementer* HandleScopeImplementer::instance() {
4456 return &thread_local; 4647 return &thread_local;
4457 } 4648 }
4458 4649
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4525 4716
4526 4717
4527 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 4718 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
4528 HandleScopeImplementer* thread_local = 4719 HandleScopeImplementer* thread_local =
4529 reinterpret_cast<HandleScopeImplementer*>(storage); 4720 reinterpret_cast<HandleScopeImplementer*>(storage);
4530 thread_local->IterateThis(v); 4721 thread_local->IterateThis(v);
4531 return storage + ArchiveSpacePerThread(); 4722 return storage + ArchiveSpacePerThread();
4532 } 4723 }
4533 4724
4534 } } // namespace v8::internal 4725 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8-profiler.h ('k') | src/heap-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698