From: yurys@chromium.org Date: Tue, 11 Jun 2013 08:32:48 +0000 (+0000) Subject: Make sure CallIC is in monomorphic state when starting profiling in NativeAccessorNam... X-Git-Tag: upstream/4.7.83~13916 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b90bd6987b78d5e0ff41c8d423d981e8b0ebf4d5;p=platform%2Fupstream%2Fv8.git Make sure CallIC is in monomorphic state when starting profiling in NativeAccessorNameInProfile2 Changed cctest/test-cpu-profiler/NativeAccessorNameInProfile2 to make a few warm-up cycles before starting profiler so that accessor invocations performed via monomorphic inline caches and slow paths traces do not distort the profile. Drive-by: removed logging code that was used to diagnose NativeAccessorNameInProfile2 failures on Windows. BUG=None R=jkummerow@chromium.org, loislo@chromium.org Review URL: https://codereview.chromium.org/16758007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15055 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index 188fbd9..a121799 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -652,15 +652,12 @@ class FooAccessorsData { public: explicit FooAccessorsData(int min_duration_ms) : min_duration_ms_(min_duration_ms), - getter_duration_(0), - setter_duration_(0), - getter_iterations_(0), - setter_iterations_(0) {} + is_warming_up_(false) {} static v8::Handle Getter(v8::Local name, const v8::AccessorInfo& info) { FooAccessorsData* data = fromInfo(info); - data->getter_duration_ = data->Wait(&data->getter_iterations_); + data->Wait(); return v8::Int32::New(2013); } @@ -668,24 +665,20 @@ class FooAccessorsData { v8::Local value, const v8::AccessorInfo& info) { FooAccessorsData* data = fromInfo(info); - data->setter_duration_ = data->Wait(&data->setter_iterations_); + data->Wait(); } - void PrintAccessorTime() { - i::OS::Print("getter: %f ms (%d); setter: %f ms (%d)\n", getter_duration_, - getter_iterations_, setter_duration_, setter_iterations_); - } + void set_warming_up(bool value) { is_warming_up_ = value; } private: - double Wait(int* iterations) { + void Wait() { + if (is_warming_up_) return; double start = i::OS::TimeCurrentMillis(); double duration = 0; while (duration < min_duration_ms_) { i::OS::Sleep(1); duration = i::OS::TimeCurrentMillis() - start; - ++*iterations; } - return duration; } static FooAccessorsData* fromInfo(const v8::AccessorInfo& info) { @@ -694,10 +687,7 @@ class FooAccessorsData { } int min_duration_ms_; - double getter_duration_; - double setter_duration_; - int getter_iterations_; - int setter_iterations_; + bool is_warming_up_; }; @@ -705,7 +695,7 @@ class FooAccessorsData { // This test checks the case when the long-running accessors are called // only once and the optimizer doesn't have chance to change the invocation // code. -TEST(NativeAccessorNameInProfile1) { +TEST(NativeAccessorUninitializedIC) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); @@ -740,7 +730,6 @@ TEST(NativeAccessorNameInProfile1) { // Dump collected profile to have a better diagnostic in case of failure. reinterpret_cast( const_cast(profile))->Print(); - accessors.PrintAccessorTime(); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); const v8::CpuProfileNode* startNode = GetChild(root, "start"); @@ -754,7 +743,7 @@ TEST(NativeAccessorNameInProfile1) { // Test that native accessors are properly reported in the CPU profile. // This test makes sure that the accessors are called enough times to become // hot and to trigger optimizations. -TEST(NativeAccessorNameInProfile2) { +TEST(NativeAccessorMonomorphicIC) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); @@ -776,6 +765,16 @@ TEST(NativeAccessorNameInProfile2) { v8::Local function = v8::Local::Cast( env->Global()->Get(v8::String::New("start"))); + { + // Make sure accessors ICs are in monomorphic state before starting + // profiling. + accessors.set_warming_up(true); + int32_t warm_up_iterations = 3; + v8::Handle args[] = { v8::Integer::New(warm_up_iterations) }; + function->Call(env->Global(), ARRAY_SIZE(args), args); + accessors.set_warming_up(false); + } + v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); v8::Local profile_name = v8::String::New("my_profile");