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

Unified Diff: test/cctest/test-cpu-profiler.cc

Issue 2053523003: Refactor CpuProfiler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/v8.gyp ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 18c009be8483e0610f1f23d14e5412a03a1a27e5..3bdf8add2b61e6256c9be558b54be25294fc2f42 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -33,6 +33,7 @@
#include "src/base/platform/platform.h"
#include "src/deoptimizer.h"
#include "src/profiler/cpu-profiler-inl.h"
+#include "src/profiler/profiler-listener.h"
#include "src/utils.h"
#include "test/cctest/cctest.h"
#include "test/cctest/profiler-extension.h"
@@ -45,6 +46,7 @@ using i::Heap;
using i::ProfileGenerator;
using i::ProfileNode;
using i::ProfilerEventsProcessor;
+using i::ProfilerListener;
using i::ScopedVector;
using i::Vector;
@@ -158,24 +160,29 @@ TEST(CodeEvents) {
CpuProfiler profiler(isolate, profiles, generator, processor);
profiles->StartProfiling("", false);
processor->Start();
+ ProfilerListener profiler_listener(isolate);
+ isolate->code_event_dispatcher()->AddListener(&profiler_listener);
+ profiler_listener.AddObserver(&profiler);
// Enqueue code creation events.
const char* aaa_str = "aaa";
i::Handle<i::String> aaa_name = factory->NewStringFromAsciiChecked(aaa_str);
- profiler.CodeCreateEvent(i::CodeEventListener::FUNCTION_TAG, aaa_code,
- *aaa_name);
- profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, comment_code,
- "comment");
- profiler.CodeCreateEvent(i::CodeEventListener::STUB_TAG, args5_code, 5);
- profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, comment2_code,
- "comment2");
- profiler.CodeMoveEvent(comment2_code, moved_code->address());
- profiler.CodeCreateEvent(i::CodeEventListener::STUB_TAG, args3_code, 3);
- profiler.CodeCreateEvent(i::CodeEventListener::STUB_TAG, args4_code, 4);
+ profiler_listener.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code,
+ *aaa_name);
+ profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code,
+ "comment");
+ profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5);
+ profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code,
+ "comment2");
+ profiler_listener.CodeMoveEvent(comment2_code, moved_code->address());
+ profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3);
+ profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4);
// Enqueue a tick event to enable code events processing.
EnqueueTickSampleEvent(processor, aaa_code->address());
+ profiler_listener.RemoveObserver(&profiler);
+ isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
processor->StopSynchronously();
// Check the state of profile generator.
@@ -221,12 +228,13 @@ TEST(TickEvents) {
CpuProfiler profiler(isolate, profiles, generator, processor);
profiles->StartProfiling("", false);
processor->Start();
+ ProfilerListener profiler_listener(isolate);
+ isolate->code_event_dispatcher()->AddListener(&profiler_listener);
+ profiler_listener.AddObserver(&profiler);
- profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, frame1_code,
- "bbb");
- profiler.CodeCreateEvent(i::CodeEventListener::STUB_TAG, frame2_code, 5);
- profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, frame3_code,
- "ddd");
+ profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb");
+ profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5);
+ profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd");
EnqueueTickSampleEvent(processor, frame1_code->instruction_start());
EnqueueTickSampleEvent(
@@ -237,6 +245,8 @@ TEST(TickEvents) {
frame2_code->instruction_end() - 1,
frame1_code->instruction_end() - 1);
+ profiler_listener.RemoveObserver(&profiler);
+ isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
processor->StopSynchronously();
CpuProfile* profile = profiles->StopProfiling("");
CHECK(profile);
@@ -257,6 +267,8 @@ TEST(TickEvents) {
const i::List<ProfileNode*>* top_down_ddd_children =
top_down_stub_children->last()->children();
CHECK_EQ(0, top_down_ddd_children->length());
+
+ isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
}
// http://crbug/51594
@@ -288,8 +300,11 @@ TEST(Issue1398) {
CpuProfiler profiler(isolate, profiles, generator, processor);
profiles->StartProfiling("", false);
processor->Start();
+ ProfilerListener profiler_listener(isolate);
+ isolate->code_event_dispatcher()->AddListener(&profiler_listener);
+ profiler_listener.AddObserver(&profiler);
- profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, code, "bbb");
+ profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb");
i::TickSample* sample = processor->StartTickSample();
sample->pc = code->address();
@@ -300,6 +315,8 @@ TEST(Issue1398) {
}
processor->FinishTickSample();
+ profiler_listener.RemoveObserver(&profiler);
+ isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
processor->StopSynchronously();
CpuProfile* profile = profiles->StopProfiling("");
CHECK(profile);
@@ -1026,17 +1043,22 @@ static void TickLines(bool optimize) {
CpuProfiler profiler(isolate, profiles, generator, processor);
profiles->StartProfiling("", false);
processor->Start();
+ ProfilerListener profiler_listener(isolate);
+ isolate->code_event_dispatcher()->AddListener(&profiler_listener);
+ profiler_listener.AddObserver(&profiler);
// Enqueue code creation events.
i::Handle<i::String> str = factory->NewStringFromAsciiChecked(func_name);
int line = 1;
int column = 1;
- profiler.CodeCreateEvent(i::CodeEventListener::FUNCTION_TAG, code,
- func->shared(), *str, line, column);
+ profiler_listener.CodeCreateEvent(i::Logger::FUNCTION_TAG, code,
+ func->shared(), *str, line, column);
// Enqueue a tick event to enable code events processing.
EnqueueTickSampleEvent(processor, code_address);
+ profiler_listener.RemoveObserver(&profiler);
+ isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
processor->StopSynchronously();
CpuProfile* profile = profiles->StopProfiling("");
@@ -1129,8 +1151,8 @@ TEST(FunctionCallSample) {
const v8::CpuProfileNode* start_node = GetChild(env.local(), root, "start");
GetChild(env.local(), start_node, "bar");
- const v8::CpuProfileNode* unresolved_node = FindChild(
- env.local(), root, i::ProfileGenerator::kUnresolvedFunctionName);
+ const v8::CpuProfileNode* unresolved_node =
+ FindChild(env.local(), root, i::CodeEntry::kUnresolvedFunctionName);
CHECK(!unresolved_node || GetChild(env.local(), unresolved_node, "call"));
profile->Delete();
@@ -1185,8 +1207,8 @@ TEST(FunctionApplySample) {
GetChild(env.local(), start_node, "test");
GetChild(env.local(), test_node, "bar");
- const v8::CpuProfileNode* unresolved_node = FindChild(
- env.local(), start_node, ProfileGenerator::kUnresolvedFunctionName);
+ const v8::CpuProfileNode* unresolved_node =
+ FindChild(env.local(), start_node, CodeEntry::kUnresolvedFunctionName);
CHECK(!unresolved_node || GetChild(env.local(), unresolved_node, "apply"));
profile->Delete();
@@ -1593,12 +1615,12 @@ TEST(IdleTime) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* program_node =
- GetChild(env.local(), root, ProfileGenerator::kProgramEntryName);
+ GetChild(env.local(), root, CodeEntry::kProgramEntryName);
CHECK_EQ(0, program_node->GetChildrenCount());
CHECK_GE(program_node->GetHitCount(), 2u);
const v8::CpuProfileNode* idle_node =
- GetChild(env.local(), root, ProfileGenerator::kIdleEntryName);
+ GetChild(env.local(), root, CodeEntry::kIdleEntryName);
CHECK_EQ(0, idle_node->GetChildrenCount());
CHECK_GE(idle_node->GetHitCount(), 3u);
« no previous file with comments | « src/v8.gyp ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698