| Index: test/cctest/test-cpu-profiler.cc
|
| diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
|
| index 188fbd948066ade0def73c4c894d1ba515aa5477..a121799939cd0b8063d7a681f9c864007c71ef31 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<v8::Value> Getter(v8::Local<v8::String> 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<v8::Value> 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<i::CpuProfile*>(
|
| const_cast<v8::CpuProfile*>(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<v8::Function> function = v8::Local<v8::Function>::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<v8::Value> 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<v8::String> profile_name = v8::String::New("my_profile");
|
|
|
|
|