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

Unified Diff: test/cctest/test-profile-generator.cc

Issue 12475016: Maintain API compatibility with older versions of V8. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | test/cctest/test-thread-termination.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-profile-generator.cc
diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc
index 56b1788a85132140bfeb0d7bea36479f0f0deb36..22b4e059a246993aa2bae921e16ed758377c23ee 100644
--- a/test/cctest/test-profile-generator.cc
+++ b/test/cctest/test-profile-generator.cc
@@ -85,8 +85,7 @@ TEST(TokenEnumerator) {
TEST(ProfileNodeFindOrAddChild) {
- ProfileTree tree;
- ProfileNode node(&tree, NULL);
+ ProfileNode node(NULL, NULL);
CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
TokenEnumerator::kNoSecurityToken);
ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
@@ -114,8 +113,7 @@ TEST(ProfileNodeFindOrAddChild) {
TEST(ProfileNodeFindOrAddChildForSameFunction) {
const char* empty = "";
const char* aaa = "aaa";
- ProfileTree tree;
- ProfileNode node(&tree, NULL);
+ ProfileNode node(NULL, NULL);
CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0,
TokenEnumerator::kNoSecurityToken);
ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
@@ -609,7 +607,7 @@ class TestSetup {
TEST(RecordTickSample) {
TestSetup test_setup;
CpuProfilesCollection profiles;
- profiles.StartProfiling("", 1, false);
+ profiles.StartProfiling("", 1);
ProfileGenerator generator(&profiles);
CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
@@ -715,88 +713,6 @@ TEST(SampleRateCalculator) {
}
-static void CheckNodeIds(ProfileNode* node, int* expectedId) {
- CHECK_EQ((*expectedId)++, node->id());
- for (int i = 0; i < node->children()->length(); i++) {
- CheckNodeIds(node->children()->at(i), expectedId);
- }
-}
-
-TEST(SampleIds) {
- TestSetup test_setup;
- CpuProfilesCollection profiles;
- profiles.StartProfiling("", 1, true);
- ProfileGenerator generator(&profiles);
- CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
- CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
- CodeEntry* entry3 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc");
- generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
- generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100);
- generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50);
-
- // We are building the following calls tree:
- // -> aaa #3 - sample1
- // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2
- // -> ccc #6 -> aaa #7 - sample3
- TickSample sample1;
- sample1.pc = ToAddress(0x1600);
- sample1.stack[0] = ToAddress(0x1510);
- sample1.frames_count = 1;
- generator.RecordTickSample(sample1);
- TickSample sample2;
- sample2.pc = ToAddress(0x1925);
- sample2.stack[0] = ToAddress(0x1780);
- sample2.stack[1] = ToAddress(0x10000); // non-existent.
- sample2.stack[2] = ToAddress(0x1620);
- sample2.frames_count = 3;
- generator.RecordTickSample(sample2);
- TickSample sample3;
- sample3.pc = ToAddress(0x1510);
- sample3.stack[0] = ToAddress(0x1910);
- sample3.stack[1] = ToAddress(0x1610);
- sample3.frames_count = 2;
- generator.RecordTickSample(sample3);
-
- CpuProfile* profile =
- profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
- int nodeId = 1;
- CheckNodeIds(profile->top_down()->root(), &nodeId);
- CHECK_EQ(7, nodeId - 1);
-
- CHECK_EQ(3, profile->samples_count());
- int expected_id[] = {3, 5, 7};
- for (int i = 0; i < 3; i++) {
- CHECK_EQ(expected_id[i], profile->sample(i)->id());
- }
-}
-
-
-TEST(NoSamples) {
- TestSetup test_setup;
- CpuProfilesCollection profiles;
- profiles.StartProfiling("", 1, false);
- ProfileGenerator generator(&profiles);
- CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
- generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
-
- // We are building the following calls tree:
- // (root)#1 -> aaa #2 -> aaa #3 - sample1
- TickSample sample1;
- sample1.pc = ToAddress(0x1600);
- sample1.stack[0] = ToAddress(0x1510);
- sample1.frames_count = 1;
- generator.RecordTickSample(sample1);
-
- CpuProfile* profile =
- profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
- int nodeId = 1;
- CheckNodeIds(profile->top_down()->root(), &nodeId);
- CHECK_EQ(3, nodeId - 1);
-
- CHECK_EQ(0, profile->samples_count());
-}
-
-
// --- P r o f i l e r E x t e n s i o n ---
class ProfilerExtension : public v8::Extension {
@@ -830,22 +746,20 @@ v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction(
v8::Handle<v8::Value> ProfilerExtension::StartProfiling(
const v8::Arguments& args) {
- v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
if (args.Length() > 0)
- cpu_profiler->StartCpuProfiling(args[0].As<v8::String>());
+ v8::CpuProfiler::StartProfiling(args[0].As<v8::String>());
else
- cpu_profiler->StartCpuProfiling(v8::String::New(""));
+ v8::CpuProfiler::StartProfiling(v8::String::New(""));
return v8::Undefined();
}
v8::Handle<v8::Value> ProfilerExtension::StopProfiling(
const v8::Arguments& args) {
- v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
if (args.Length() > 0)
- cpu_profiler->StopCpuProfiling(args[0].As<v8::String>());
+ v8::CpuProfiler::StopProfiling(args[0].As<v8::String>());
else
- cpu_profiler->StopCpuProfiling(v8::String::New(""));
+ v8::CpuProfiler::StopProfiling(v8::String::New(""));
return v8::Undefined();
}
@@ -878,16 +792,16 @@ TEST(RecordStackTraceAtStartProfiling) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
env->Enter();
- CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
- CHECK_EQ(0, profiler->GetProfilesCount());
+ CHECK_EQ(0, CpuProfiler::GetProfilesCount());
CompileRun(
"function c() { startProfiling(); }\n"
"function b() { c(); }\n"
"function a() { b(); }\n"
"a();\n"
"stopProfiling();");
- CHECK_EQ(1, profiler->GetProfilesCount());
- CpuProfile* profile = profiler->GetProfile(NULL, 0);
+ CHECK_EQ(1, CpuProfiler::GetProfilesCount());
+ CpuProfile* profile =
+ CpuProfiler::GetProfile(NULL, 0);
const ProfileTree* topDown = profile->top_down();
const ProfileNode* current = topDown->root();
const_cast<ProfileNode*>(current)->Print(0);
@@ -924,12 +838,11 @@ TEST(Issue51919) {
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) {
i::Vector<char> title = i::Vector<char>::New(16);
i::OS::SNPrintF(title, "%d", i);
- // UID must be > 0.
- CHECK(collection.StartProfiling(title.start(), i + 1, false));
+ CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0.
titles[i] = title.start();
}
CHECK(!collection.StartProfiling(
- "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false));
+ "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1));
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
i::DeleteArray(titles[i]);
}
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | test/cctest/test-thread-termination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698