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

Side by Side Diff: src/api.cc

Issue 12907006: Isolatify HeapProfiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Prohibited construction and destruction of v8::HeapProfiler Created 7 years, 9 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 | Annotate | Revision Log
« 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 5789 matching lines...) Expand 10 before | Expand all | Expand 10 after
5800 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 5800 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
5801 if (isolate == NULL || !isolate->IsInitialized() || 5801 if (isolate == NULL || !isolate->IsInitialized() ||
5802 IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) { 5802 IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) {
5803 return 0; 5803 return 0;
5804 } 5804 }
5805 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate); 5805 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate);
5806 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); 5806 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
5807 } 5807 }
5808 5808
5809 5809
5810 HeapProfiler* Isolate::GetHeapProfiler() {
5811 i::HeapProfiler* heap_profiler =
5812 reinterpret_cast<i::Isolate*>(this)->heap_profiler();
5813 return reinterpret_cast<HeapProfiler*>(heap_profiler);
5814 }
5815
5816
5810 void V8::SetGlobalGCPrologueCallback(GCCallback callback) { 5817 void V8::SetGlobalGCPrologueCallback(GCCallback callback) {
5811 i::Isolate* isolate = i::Isolate::Current(); 5818 i::Isolate* isolate = i::Isolate::Current();
5812 if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCPrologueCallback()")) return; 5819 if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCPrologueCallback()")) return;
5813 isolate->heap()->SetGlobalGCPrologueCallback(callback); 5820 isolate->heap()->SetGlobalGCPrologueCallback(callback);
5814 } 5821 }
5815 5822
5816 5823
5817 void V8::SetGlobalGCEpilogueCallback(GCCallback callback) { 5824 void V8::SetGlobalGCEpilogueCallback(GCCallback callback) {
5818 i::Isolate* isolate = i::Isolate::Current(); 5825 i::Isolate* isolate = i::Isolate::Current();
5819 if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCEpilogueCallback()")) return; 5826 if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCEpilogueCallback()")) return;
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
6701 6708
6702 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { 6709 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
6703 return const_cast<i::HeapSnapshot*>( 6710 return const_cast<i::HeapSnapshot*>(
6704 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); 6711 reinterpret_cast<const i::HeapSnapshot*>(snapshot));
6705 } 6712 }
6706 6713
6707 6714
6708 void HeapSnapshot::Delete() { 6715 void HeapSnapshot::Delete() {
6709 i::Isolate* isolate = i::Isolate::Current(); 6716 i::Isolate* isolate = i::Isolate::Current();
6710 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); 6717 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete");
6711 if (i::HeapProfiler::GetSnapshotsCount() > 1) { 6718 if (isolate->heap_profiler()->GetSnapshotsCount() > 1) {
6712 ToInternal(this)->Delete(); 6719 ToInternal(this)->Delete();
6713 } else { 6720 } else {
6714 // If this is the last snapshot, clean up all accessory data as well. 6721 // If this is the last snapshot, clean up all accessory data as well.
6715 i::HeapProfiler::DeleteAllSnapshots(); 6722 isolate->heap_profiler()->DeleteAllSnapshots();
6716 } 6723 }
6717 } 6724 }
6718 6725
6719 6726
6720 HeapSnapshot::Type HeapSnapshot::GetType() const { 6727 HeapSnapshot::Type HeapSnapshot::GetType() const {
6721 i::Isolate* isolate = i::Isolate::Current(); 6728 i::Isolate* isolate = i::Isolate::Current();
6722 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType"); 6729 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType");
6723 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type()); 6730 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type());
6724 } 6731 }
6725 6732
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
6790 "v8::HeapSnapshot::Serialize", 6797 "v8::HeapSnapshot::Serialize",
6791 "Invalid stream chunk size"); 6798 "Invalid stream chunk size");
6792 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); 6799 i::HeapSnapshotJSONSerializer serializer(ToInternal(this));
6793 serializer.Serialize(stream); 6800 serializer.Serialize(stream);
6794 } 6801 }
6795 6802
6796 6803
6797 int HeapProfiler::GetSnapshotsCount() { 6804 int HeapProfiler::GetSnapshotsCount() {
6798 i::Isolate* isolate = i::Isolate::Current(); 6805 i::Isolate* isolate = i::Isolate::Current();
6799 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount"); 6806 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount");
6800 return i::HeapProfiler::GetSnapshotsCount(); 6807 return isolate->heap_profiler()->GetSnapshotsCount();
6801 } 6808 }
6802 6809
6803 6810
6811 int HeapProfiler::GetSnapshotCount() {
6812 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount();
6813 }
6814
6815
6804 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) { 6816 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) {
6805 i::Isolate* isolate = i::Isolate::Current(); 6817 i::Isolate* isolate = i::Isolate::Current();
6806 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot"); 6818 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot");
6807 return reinterpret_cast<const HeapSnapshot*>( 6819 return reinterpret_cast<const HeapSnapshot*>(
6808 i::HeapProfiler::GetSnapshot(index)); 6820 isolate->heap_profiler()->GetSnapshot(index));
6809 } 6821 }
6810 6822
6811 6823
6824 const HeapSnapshot* HeapProfiler::GetHeapSnapshot(int index) {
6825 return reinterpret_cast<const HeapSnapshot*>(
6826 reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index));
6827 }
6828
6829
6812 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) { 6830 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {
6813 i::Isolate* isolate = i::Isolate::Current(); 6831 i::Isolate* isolate = i::Isolate::Current();
6814 IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot"); 6832 IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot");
6815 return reinterpret_cast<const HeapSnapshot*>( 6833 return reinterpret_cast<const HeapSnapshot*>(
6816 i::HeapProfiler::FindSnapshot(uid)); 6834 isolate->heap_profiler()->FindSnapshot(uid));
6817 } 6835 }
6818 6836
6819 6837
6838 const HeapSnapshot* HeapProfiler::FindHeapSnapshot(unsigned uid) {
6839 return reinterpret_cast<const HeapSnapshot*>(
6840 reinterpret_cast<i::HeapProfiler*>(this)->FindSnapshot(uid));
6841 }
6842
6843
6820 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Value> value) { 6844 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Value> value) {
6821 i::Isolate* isolate = i::Isolate::Current(); 6845 i::Isolate* isolate = i::Isolate::Current();
6822 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotObjectId"); 6846 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotObjectId");
6823 i::Handle<i::Object> obj = Utils::OpenHandle(*value); 6847 i::Handle<i::Object> obj = Utils::OpenHandle(*value);
6824 return i::HeapProfiler::GetSnapshotObjectId(obj); 6848 return isolate->heap_profiler()->GetSnapshotObjectId(obj);
6825 } 6849 }
6826 6850
6827 6851
6852 SnapshotObjectId HeapProfiler::GetObjectId(Handle<Value> value) {
6853 i::Handle<i::Object> obj = Utils::OpenHandle(*value);
6854 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj);
6855 }
6856
6857
6828 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title, 6858 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
6829 HeapSnapshot::Type type, 6859 HeapSnapshot::Type type,
6830 ActivityControl* control, 6860 ActivityControl* control,
6831 ObjectNameResolver* resolver) { 6861 ObjectNameResolver* resolver) {
6832 i::Isolate* isolate = i::Isolate::Current(); 6862 i::Isolate* isolate = i::Isolate::Current();
6833 IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot"); 6863 IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot");
6834 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull; 6864 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull;
6835 switch (type) { 6865 switch (type) {
6836 case HeapSnapshot::kFull: 6866 case HeapSnapshot::kFull:
6837 internal_type = i::HeapSnapshot::kFull; 6867 internal_type = i::HeapSnapshot::kFull;
6838 break; 6868 break;
6839 default: 6869 default:
6840 UNREACHABLE(); 6870 UNREACHABLE();
6841 } 6871 }
6842 return reinterpret_cast<const HeapSnapshot*>( 6872 return reinterpret_cast<const HeapSnapshot*>(
6843 i::HeapProfiler::TakeSnapshot( 6873 isolate->heap_profiler()->TakeSnapshot(
6844 *Utils::OpenHandle(*title), internal_type, control, resolver)); 6874 *Utils::OpenHandle(*title), internal_type, control, resolver));
6845 } 6875 }
6846 6876
6847 6877
6878 const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(
6879 Handle<String> title,
6880 ActivityControl* control,
6881 ObjectNameResolver* resolver) {
6882 return reinterpret_cast<const HeapSnapshot*>(
6883 reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot(
6884 *Utils::OpenHandle(*title), i::HeapSnapshot::kFull,
6885 control, resolver));
6886 }
6887
6888
6848 void HeapProfiler::StartHeapObjectsTracking() { 6889 void HeapProfiler::StartHeapObjectsTracking() {
6849 i::Isolate* isolate = i::Isolate::Current(); 6890 i::Isolate* isolate = i::Isolate::Current();
6850 IsDeadCheck(isolate, "v8::HeapProfiler::StartHeapObjectsTracking"); 6891 IsDeadCheck(isolate, "v8::HeapProfiler::StartHeapObjectsTracking");
6851 i::HeapProfiler::StartHeapObjectsTracking(); 6892 isolate->heap_profiler()->StartHeapObjectsTracking();
6893 }
6894
6895
6896 void HeapProfiler::StartTrackingHeapObjects() {
6897 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking();
6852 } 6898 }
6853 6899
6854 6900
6855 void HeapProfiler::StopHeapObjectsTracking() { 6901 void HeapProfiler::StopHeapObjectsTracking() {
6856 i::Isolate* isolate = i::Isolate::Current(); 6902 i::Isolate* isolate = i::Isolate::Current();
6857 IsDeadCheck(isolate, "v8::HeapProfiler::StopHeapObjectsTracking"); 6903 IsDeadCheck(isolate, "v8::HeapProfiler::StopHeapObjectsTracking");
6858 i::HeapProfiler::StopHeapObjectsTracking(); 6904 isolate->heap_profiler()->StopHeapObjectsTracking();
6905 }
6906
6907
6908 void HeapProfiler::StopTrackingHeapObjects() {
6909 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking();
6859 } 6910 }
6860 6911
6861 6912
6862 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) { 6913 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
6863 i::Isolate* isolate = i::Isolate::Current(); 6914 i::Isolate* isolate = i::Isolate::Current();
6864 IsDeadCheck(isolate, "v8::HeapProfiler::PushHeapObjectsStats"); 6915 IsDeadCheck(isolate, "v8::HeapProfiler::PushHeapObjectsStats");
6865 return i::HeapProfiler::PushHeapObjectsStats(stream); 6916 return isolate->heap_profiler()->PushHeapObjectsStats(stream);
6917 }
6918
6919
6920 SnapshotObjectId HeapProfiler::GetHeapStats(OutputStream* stream) {
6921 return reinterpret_cast<i::HeapProfiler*>(this)->PushHeapObjectsStats(stream);
6866 } 6922 }
6867 6923
6868 6924
6869 void HeapProfiler::DeleteAllSnapshots() { 6925 void HeapProfiler::DeleteAllSnapshots() {
6870 i::Isolate* isolate = i::Isolate::Current(); 6926 i::Isolate* isolate = i::Isolate::Current();
6871 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots"); 6927 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots");
6872 i::HeapProfiler::DeleteAllSnapshots(); 6928 isolate->heap_profiler()->DeleteAllSnapshots();
6873 } 6929 }
6874 6930
6875 6931
6932 void HeapProfiler::DeleteAllHeapSnapshots() {
6933 reinterpret_cast<i::HeapProfiler*>(this)->DeleteAllSnapshots();
6934 }
6935
6936
6876 void HeapProfiler::DefineWrapperClass(uint16_t class_id, 6937 void HeapProfiler::DefineWrapperClass(uint16_t class_id,
6877 WrapperInfoCallback callback) { 6938 WrapperInfoCallback callback) {
6878 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id, 6939 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id,
6879 callback); 6940 callback);
6880 } 6941 }
6881 6942
6882 6943
6944 void HeapProfiler::SetWrapperClassInfoProvider(uint16_t class_id,
6945 WrapperInfoCallback callback) {
6946 reinterpret_cast<i::HeapProfiler*>(this)->DefineWrapperClass(class_id,
6947 callback);
6948 }
6949
6950
6883 int HeapProfiler::GetPersistentHandleCount() { 6951 int HeapProfiler::GetPersistentHandleCount() {
6884 i::Isolate* isolate = i::Isolate::Current(); 6952 i::Isolate* isolate = i::Isolate::Current();
6885 return isolate->global_handles()->NumberOfGlobalHandles(); 6953 return isolate->global_handles()->NumberOfGlobalHandles();
6886 } 6954 }
6887 6955
6888 6956
6889 size_t HeapProfiler::GetMemorySizeUsedByProfiler() { 6957 size_t HeapProfiler::GetMemorySizeUsedByProfiler() {
6890 return i::HeapProfiler::GetMemorySizeUsedByProfiler(); 6958 return i::Isolate::Current()->heap_profiler()->GetMemorySizeUsedByProfiler();
6891 } 6959 }
6892 6960
6893 6961
6962 size_t HeapProfiler::GetProfilerMemorySize() {
6963 return reinterpret_cast<i::HeapProfiler*>(this)->
6964 GetMemorySizeUsedByProfiler();
6965 }
6966
6967
6894 v8::Testing::StressType internal::Testing::stress_type_ = 6968 v8::Testing::StressType internal::Testing::stress_type_ =
6895 v8::Testing::kStressTypeOpt; 6969 v8::Testing::kStressTypeOpt;
6896 6970
6897 6971
6898 void Testing::SetStressRunType(Testing::StressType type) { 6972 void Testing::SetStressRunType(Testing::StressType type) {
6899 internal::Testing::set_stress_type(type); 6973 internal::Testing::set_stress_type(type);
6900 } 6974 }
6901 6975
6902 int Testing::GetStressRuns() { 6976 int Testing::GetStressRuns() {
6903 if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs; 6977 if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
7098 7172
7099 v->VisitPointers(blocks_.first(), first_block_limit_); 7173 v->VisitPointers(blocks_.first(), first_block_limit_);
7100 7174
7101 for (int i = 1; i < blocks_.length(); i++) { 7175 for (int i = 1; i < blocks_.length(); i++) {
7102 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 7176 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
7103 } 7177 }
7104 } 7178 }
7105 7179
7106 7180
7107 } } // namespace v8::internal 7181 } } // 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