Commit 9974d932 authored by yurys@chromium.org's avatar yurys@chromium.org

Deprecate profiler methods that accept security origin

Now that the only known client console.profiles was removed from Blink:
https://src.chromium.org/viewvc/blink?revision=151136&view=revision
https://src.chromium.org/viewvc/blink?revision=151196&view=revision
this method can be deprecated and all the code that supports filtering
CPU profiles based on security origins can be later removed.

Drive-by fix: in line with CpuProfiler changes deprecated HeapProfiler::FindHeapSnapshot to reduce v8 API surface. FindHeapSnapshot may well be implemented based on existing GetSnapshotCount/GetSnapshot and it is only used in the tests.

BUG=None
R=jkummerow@chromium.org, loislo@chromium.org

Review URL: https://codereview.chromium.org/16114002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14833 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4fcaace0
...@@ -184,19 +184,21 @@ class V8EXPORT CpuProfiler { ...@@ -184,19 +184,21 @@ class V8EXPORT CpuProfiler {
V8_DEPRECATED(static const CpuProfile* GetProfile( V8_DEPRECATED(static const CpuProfile* GetProfile(
int index, int index,
Handle<Value> security_token = Handle<Value>())); Handle<Value> security_token = Handle<Value>()));
/** Returns a profile by index. */ /** Deprecated. Use GetCpuProfile with single parameter. */
const CpuProfile* GetCpuProfile( V8_DEPRECATED(const CpuProfile* GetCpuProfile(
int index, int index,
Handle<Value> security_token = Handle<Value>()); Handle<Value> security_token));
/** Returns a profile by index. */
const CpuProfile* GetCpuProfile(int index);
/** Deprecated. Use FindProfile instead. */ /** Deprecated. Use FindProfile instead. */
V8_DEPRECATED(static const CpuProfile* FindProfile( V8_DEPRECATED(static const CpuProfile* FindProfile(
unsigned uid, unsigned uid,
Handle<Value> security_token = Handle<Value>())); Handle<Value> security_token = Handle<Value>()));
/** Returns a profile by uid. */ /** Returns a profile by uid. */
const CpuProfile* FindCpuProfile( V8_DEPRECATED(const CpuProfile* FindCpuProfile(
unsigned uid, unsigned uid,
Handle<Value> security_token = Handle<Value>()); Handle<Value> security_token = Handle<Value>()));
/** Deprecated. Use StartCpuProfiling instead. */ /** Deprecated. Use StartCpuProfiling instead. */
V8_DEPRECATED(static void StartProfiling(Handle<String> title, V8_DEPRECATED(static void StartProfiling(Handle<String> title,
...@@ -218,13 +220,17 @@ class V8EXPORT CpuProfiler { ...@@ -218,13 +220,17 @@ class V8EXPORT CpuProfiler {
V8_DEPRECATED(static const CpuProfile* StopProfiling( V8_DEPRECATED(static const CpuProfile* StopProfiling(
Handle<String> title, Handle<String> title,
Handle<Value> security_token = Handle<Value>())); Handle<Value> security_token = Handle<Value>()));
/**
* Deprecated. Use StopCpuProfiling with one parameter instead.
*/
V8_DEPRECATED(const CpuProfile* StopCpuProfiling(
Handle<String> title,
Handle<Value> security_token));
/** /**
* Stops collecting CPU profile with a given title and returns it. * Stops collecting CPU profile with a given title and returns it.
* If the title given is empty, finishes the last profile started. * If the title given is empty, finishes the last profile started.
*/ */
const CpuProfile* StopCpuProfiling( const CpuProfile* StopCpuProfiling(Handle<String> title);
Handle<String> title,
Handle<Value> security_token = Handle<Value>());
/** Deprecated. Use DeleteAllCpuProfiles instead. */ /** Deprecated. Use DeleteAllCpuProfiles instead. */
V8_DEPRECATED(static void DeleteAllProfiles()); V8_DEPRECATED(static void DeleteAllProfiles());
...@@ -438,7 +444,7 @@ class V8EXPORT HeapProfiler { ...@@ -438,7 +444,7 @@ class V8EXPORT HeapProfiler {
/** Deprecated. Use FindHeapSnapshot instead. */ /** Deprecated. Use FindHeapSnapshot instead. */
V8_DEPRECATED(static const HeapSnapshot* FindSnapshot(unsigned uid)); V8_DEPRECATED(static const HeapSnapshot* FindSnapshot(unsigned uid));
/** Returns a profile by uid. */ /** Returns a profile by uid. */
const HeapSnapshot* FindHeapSnapshot(unsigned uid); V8_DEPRECATED(const HeapSnapshot* FindHeapSnapshot(unsigned uid));
/** Deprecated. Use GetObjectId instead. */ /** Deprecated. Use GetObjectId instead. */
V8_DEPRECATED(static SnapshotObjectId GetSnapshotObjectId( V8_DEPRECATED(static SnapshotObjectId GetSnapshotObjectId(
......
...@@ -7243,6 +7243,12 @@ const CpuProfile* CpuProfiler::GetCpuProfile(int index, ...@@ -7243,6 +7243,12 @@ const CpuProfile* CpuProfiler::GetCpuProfile(int index,
} }
const CpuProfile* CpuProfiler::GetCpuProfile(int index) {
return reinterpret_cast<const CpuProfile*>(
reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(NULL, index));
}
const CpuProfile* CpuProfiler::FindProfile(unsigned uid, const CpuProfile* CpuProfiler::FindProfile(unsigned uid,
Handle<Value> security_token) { Handle<Value> security_token) {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
...@@ -7302,6 +7308,14 @@ const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title, ...@@ -7302,6 +7308,14 @@ const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title,
} }
const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) {
return reinterpret_cast<const CpuProfile*>(
reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling(
NULL,
*Utils::OpenHandle(*title)));
}
void CpuProfiler::DeleteAllProfiles() { void CpuProfiler::DeleteAllProfiles() {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles"); IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles");
......
...@@ -31,11 +31,13 @@ ...@@ -31,11 +31,13 @@
#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW #define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
#define V8_DISABLE_DEPRECATIONS 1
#include "v8.h" #include "v8.h"
#include "cpu-profiler-inl.h" #include "cpu-profiler-inl.h"
#include "cctest.h" #include "cctest.h"
#include "utils.h" #include "utils.h"
#include "../include/v8-profiler.h" #include "../include/v8-profiler.h"
#undef V8_DISABLE_DEPRECATIONS
using i::CodeEntry; using i::CodeEntry;
using i::CpuProfile; using i::CpuProfile;
...@@ -297,6 +299,19 @@ TEST(DeleteAllCpuProfiles) { ...@@ -297,6 +299,19 @@ TEST(DeleteAllCpuProfiles) {
} }
static const v8::CpuProfile* FindCpuProfile(v8::CpuProfiler* profiler,
unsigned uid) {
int length = profiler->GetProfileCount();
for (int i = 0; i < length; i++) {
const v8::CpuProfile* profile = profiler->GetCpuProfile(i);
if (profile->GetUid() == uid) {
return profile;
}
}
return NULL;
}
TEST(DeleteCpuProfile) { TEST(DeleteCpuProfile) {
LocalContext env; LocalContext env;
v8::HandleScope scope(env->GetIsolate()); v8::HandleScope scope(env->GetIsolate());
...@@ -309,10 +324,10 @@ TEST(DeleteCpuProfile) { ...@@ -309,10 +324,10 @@ TEST(DeleteCpuProfile) {
CHECK_NE(NULL, p1); CHECK_NE(NULL, p1);
CHECK_EQ(1, cpu_profiler->GetProfileCount()); CHECK_EQ(1, cpu_profiler->GetProfileCount());
unsigned uid1 = p1->GetUid(); unsigned uid1 = p1->GetUid();
CHECK_EQ(p1, cpu_profiler->FindCpuProfile(uid1)); CHECK_EQ(p1, FindCpuProfile(cpu_profiler, uid1));
const_cast<v8::CpuProfile*>(p1)->Delete(); const_cast<v8::CpuProfile*>(p1)->Delete();
CHECK_EQ(0, cpu_profiler->GetProfileCount()); CHECK_EQ(0, cpu_profiler->GetProfileCount());
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
v8::Local<v8::String> name2 = v8::String::New("2"); v8::Local<v8::String> name2 = v8::String::New("2");
cpu_profiler->StartCpuProfiling(name2); cpu_profiler->StartCpuProfiling(name2);
...@@ -321,8 +336,8 @@ TEST(DeleteCpuProfile) { ...@@ -321,8 +336,8 @@ TEST(DeleteCpuProfile) {
CHECK_EQ(1, cpu_profiler->GetProfileCount()); CHECK_EQ(1, cpu_profiler->GetProfileCount());
unsigned uid2 = p2->GetUid(); unsigned uid2 = p2->GetUid();
CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
CHECK_EQ(p2, cpu_profiler->FindCpuProfile(uid2)); CHECK_EQ(p2, FindCpuProfile(cpu_profiler, uid2));
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
v8::Local<v8::String> name3 = v8::String::New("3"); v8::Local<v8::String> name3 = v8::String::New("3");
cpu_profiler->StartCpuProfiling(name3); cpu_profiler->StartCpuProfiling(name3);
const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3); const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3);
...@@ -330,17 +345,17 @@ TEST(DeleteCpuProfile) { ...@@ -330,17 +345,17 @@ TEST(DeleteCpuProfile) {
CHECK_EQ(2, cpu_profiler->GetProfileCount()); CHECK_EQ(2, cpu_profiler->GetProfileCount());
unsigned uid3 = p3->GetUid(); unsigned uid3 = p3->GetUid();
CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3));
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
const_cast<v8::CpuProfile*>(p2)->Delete(); const_cast<v8::CpuProfile*>(p2)->Delete();
CHECK_EQ(1, cpu_profiler->GetProfileCount()); CHECK_EQ(1, cpu_profiler->GetProfileCount());
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2));
CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3));
const_cast<v8::CpuProfile*>(p3)->Delete(); const_cast<v8::CpuProfile*>(p3)->Delete();
CHECK_EQ(0, cpu_profiler->GetProfileCount()); CHECK_EQ(0, cpu_profiler->GetProfileCount());
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3)); CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid3));
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2));
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
} }
......
...@@ -1285,6 +1285,19 @@ TEST(DeleteAllHeapSnapshots) { ...@@ -1285,6 +1285,19 @@ TEST(DeleteAllHeapSnapshots) {
} }
static const v8::HeapSnapshot* FindHeapSnapshot(v8::HeapProfiler* profiler,
unsigned uid) {
int length = profiler->GetSnapshotCount();
for (int i = 0; i < length; i++) {
const v8::HeapSnapshot* snapshot = profiler->GetHeapSnapshot(i);
if (snapshot->GetUid() == uid) {
return snapshot;
}
}
return NULL;
}
TEST(DeleteHeapSnapshot) { TEST(DeleteHeapSnapshot) {
LocalContext env; LocalContext env;
v8::HandleScope scope(env->GetIsolate()); v8::HandleScope scope(env->GetIsolate());
...@@ -1296,10 +1309,10 @@ TEST(DeleteHeapSnapshot) { ...@@ -1296,10 +1309,10 @@ TEST(DeleteHeapSnapshot) {
CHECK_NE(NULL, s1); CHECK_NE(NULL, s1);
CHECK_EQ(1, heap_profiler->GetSnapshotCount()); CHECK_EQ(1, heap_profiler->GetSnapshotCount());
unsigned uid1 = s1->GetUid(); unsigned uid1 = s1->GetUid();
CHECK_EQ(s1, heap_profiler->FindHeapSnapshot(uid1)); CHECK_EQ(s1, FindHeapSnapshot(heap_profiler, uid1));
const_cast<v8::HeapSnapshot*>(s1)->Delete(); const_cast<v8::HeapSnapshot*>(s1)->Delete();
CHECK_EQ(0, heap_profiler->GetSnapshotCount()); CHECK_EQ(0, heap_profiler->GetSnapshotCount());
CHECK_EQ(NULL, heap_profiler->FindHeapSnapshot(uid1)); CHECK_EQ(NULL, FindHeapSnapshot(heap_profiler, uid1));
const v8::HeapSnapshot* s2 = const v8::HeapSnapshot* s2 =
heap_profiler->TakeHeapSnapshot(v8_str("2")); heap_profiler->TakeHeapSnapshot(v8_str("2"));
...@@ -1307,21 +1320,21 @@ TEST(DeleteHeapSnapshot) { ...@@ -1307,21 +1320,21 @@ TEST(DeleteHeapSnapshot) {
CHECK_EQ(1, heap_profiler->GetSnapshotCount()); CHECK_EQ(1, heap_profiler->GetSnapshotCount());
unsigned uid2 = s2->GetUid(); unsigned uid2 = s2->GetUid();
CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
CHECK_EQ(s2, heap_profiler->FindHeapSnapshot(uid2)); CHECK_EQ(s2, FindHeapSnapshot(heap_profiler, uid2));
const v8::HeapSnapshot* s3 = const v8::HeapSnapshot* s3 =
heap_profiler->TakeHeapSnapshot(v8_str("3")); heap_profiler->TakeHeapSnapshot(v8_str("3"));
CHECK_NE(NULL, s3); CHECK_NE(NULL, s3);
CHECK_EQ(2, heap_profiler->GetSnapshotCount()); CHECK_EQ(2, heap_profiler->GetSnapshotCount());
unsigned uid3 = s3->GetUid(); unsigned uid3 = s3->GetUid();
CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
CHECK_EQ(s3, heap_profiler->FindHeapSnapshot(uid3)); CHECK_EQ(s3, FindHeapSnapshot(heap_profiler, uid3));
const_cast<v8::HeapSnapshot*>(s2)->Delete(); const_cast<v8::HeapSnapshot*>(s2)->Delete();
CHECK_EQ(1, heap_profiler->GetSnapshotCount()); CHECK_EQ(1, heap_profiler->GetSnapshotCount());
CHECK_EQ(NULL, heap_profiler->FindHeapSnapshot(uid2)); CHECK_EQ(NULL, FindHeapSnapshot(heap_profiler, uid2));
CHECK_EQ(s3, heap_profiler->FindHeapSnapshot(uid3)); CHECK_EQ(s3, FindHeapSnapshot(heap_profiler, uid3));
const_cast<v8::HeapSnapshot*>(s3)->Delete(); const_cast<v8::HeapSnapshot*>(s3)->Delete();
CHECK_EQ(0, heap_profiler->GetSnapshotCount()); CHECK_EQ(0, heap_profiler->GetSnapshotCount());
CHECK_EQ(NULL, heap_profiler->FindHeapSnapshot(uid3)); CHECK_EQ(NULL, FindHeapSnapshot(heap_profiler, uid3));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment