| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return abs(static_cast<int>(a) - static_cast<int>(b)); | 71 return abs(static_cast<int>(a) - static_cast<int>(b)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 static const char* reason(const i::DeoptimizeReason reason) { | 74 static const char* reason(const i::DeoptimizeReason reason) { |
| 75 return i::DeoptimizeReasonToString(reason); | 75 return i::DeoptimizeReasonToString(reason); |
| 76 } | 76 } |
| 77 | 77 |
| 78 TEST(StartStop) { | 78 TEST(StartStop) { |
| 79 i::Isolate* isolate = CcTest::i_isolate(); | 79 i::Isolate* isolate = CcTest::i_isolate(); |
| 80 CpuProfilesCollection profiles(isolate); | 80 CpuProfilesCollection profiles(isolate); |
| 81 ProfileGenerator generator(isolate, &profiles); | 81 ProfileGenerator generator(&profiles); |
| 82 std::unique_ptr<ProfilerEventsProcessor> processor( | 82 std::unique_ptr<ProfilerEventsProcessor> processor( |
| 83 new ProfilerEventsProcessor(isolate, &generator, | 83 new ProfilerEventsProcessor(isolate, &generator, |
| 84 v8::base::TimeDelta::FromMicroseconds(100))); | 84 v8::base::TimeDelta::FromMicroseconds(100))); |
| 85 processor->Start(); | 85 processor->Start(); |
| 86 processor->StopSynchronously(); | 86 processor->StopSynchronously(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, | 89 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, |
| 90 i::Address frame1, | 90 i::Address frame1, |
| 91 i::Address frame2 = NULL, | 91 i::Address frame2 = NULL, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 i::AbstractCode* aaa_code = CreateCode(&env); | 157 i::AbstractCode* aaa_code = CreateCode(&env); |
| 158 i::AbstractCode* comment_code = CreateCode(&env); | 158 i::AbstractCode* comment_code = CreateCode(&env); |
| 159 i::AbstractCode* args5_code = CreateCode(&env); | 159 i::AbstractCode* args5_code = CreateCode(&env); |
| 160 i::AbstractCode* comment2_code = CreateCode(&env); | 160 i::AbstractCode* comment2_code = CreateCode(&env); |
| 161 i::AbstractCode* moved_code = CreateCode(&env); | 161 i::AbstractCode* moved_code = CreateCode(&env); |
| 162 i::AbstractCode* args3_code = CreateCode(&env); | 162 i::AbstractCode* args3_code = CreateCode(&env); |
| 163 i::AbstractCode* args4_code = CreateCode(&env); | 163 i::AbstractCode* args4_code = CreateCode(&env); |
| 164 | 164 |
| 165 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); | 165 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); |
| 166 ProfileGenerator* generator = new ProfileGenerator(isolate, profiles); | 166 ProfileGenerator* generator = new ProfileGenerator(profiles); |
| 167 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( | 167 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( |
| 168 isolate, generator, v8::base::TimeDelta::FromMicroseconds(100)); | 168 isolate, generator, v8::base::TimeDelta::FromMicroseconds(100)); |
| 169 CpuProfiler profiler(isolate, profiles, generator, processor); | 169 CpuProfiler profiler(isolate, profiles, generator, processor); |
| 170 profiles->StartProfiling("", false); | 170 profiles->StartProfiling("", false); |
| 171 processor->Start(); | 171 processor->Start(); |
| 172 ProfilerListener profiler_listener(isolate); | 172 ProfilerListener profiler_listener(isolate); |
| 173 isolate->code_event_dispatcher()->AddListener(&profiler_listener); | 173 isolate->code_event_dispatcher()->AddListener(&profiler_listener); |
| 174 profiler_listener.AddObserver(&profiler); | 174 profiler_listener.AddObserver(&profiler); |
| 175 | 175 |
| 176 // Enqueue code creation events. | 176 // Enqueue code creation events. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 TestSetup test_setup; | 224 TestSetup test_setup; |
| 225 LocalContext env; | 225 LocalContext env; |
| 226 i::Isolate* isolate = CcTest::i_isolate(); | 226 i::Isolate* isolate = CcTest::i_isolate(); |
| 227 i::HandleScope scope(isolate); | 227 i::HandleScope scope(isolate); |
| 228 | 228 |
| 229 i::AbstractCode* frame1_code = CreateCode(&env); | 229 i::AbstractCode* frame1_code = CreateCode(&env); |
| 230 i::AbstractCode* frame2_code = CreateCode(&env); | 230 i::AbstractCode* frame2_code = CreateCode(&env); |
| 231 i::AbstractCode* frame3_code = CreateCode(&env); | 231 i::AbstractCode* frame3_code = CreateCode(&env); |
| 232 | 232 |
| 233 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); | 233 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); |
| 234 ProfileGenerator* generator = new ProfileGenerator(isolate, profiles); | 234 ProfileGenerator* generator = new ProfileGenerator(profiles); |
| 235 ProfilerEventsProcessor* processor = | 235 ProfilerEventsProcessor* processor = |
| 236 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, | 236 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, |
| 237 v8::base::TimeDelta::FromMicroseconds(100)); | 237 v8::base::TimeDelta::FromMicroseconds(100)); |
| 238 CpuProfiler profiler(isolate, profiles, generator, processor); | 238 CpuProfiler profiler(isolate, profiles, generator, processor); |
| 239 profiles->StartProfiling("", false); | 239 profiles->StartProfiling("", false); |
| 240 processor->Start(); | 240 processor->Start(); |
| 241 ProfilerListener profiler_listener(isolate); | 241 ProfilerListener profiler_listener(isolate); |
| 242 isolate->code_event_dispatcher()->AddListener(&profiler_listener); | 242 isolate->code_event_dispatcher()->AddListener(&profiler_listener); |
| 243 profiler_listener.AddObserver(&profiler); | 243 profiler_listener.AddObserver(&profiler); |
| 244 | 244 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 // Long stacks (exceeding max frames limit) must not be erased. | 297 // Long stacks (exceeding max frames limit) must not be erased. |
| 298 TEST(Issue1398) { | 298 TEST(Issue1398) { |
| 299 TestSetup test_setup; | 299 TestSetup test_setup; |
| 300 LocalContext env; | 300 LocalContext env; |
| 301 i::Isolate* isolate = CcTest::i_isolate(); | 301 i::Isolate* isolate = CcTest::i_isolate(); |
| 302 i::HandleScope scope(isolate); | 302 i::HandleScope scope(isolate); |
| 303 | 303 |
| 304 i::AbstractCode* code = CreateCode(&env); | 304 i::AbstractCode* code = CreateCode(&env); |
| 305 | 305 |
| 306 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); | 306 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); |
| 307 ProfileGenerator* generator = new ProfileGenerator(isolate, profiles); | 307 ProfileGenerator* generator = new ProfileGenerator(profiles); |
| 308 ProfilerEventsProcessor* processor = | 308 ProfilerEventsProcessor* processor = |
| 309 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, | 309 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, |
| 310 v8::base::TimeDelta::FromMicroseconds(100)); | 310 v8::base::TimeDelta::FromMicroseconds(100)); |
| 311 CpuProfiler profiler(isolate, profiles, generator, processor); | 311 CpuProfiler profiler(isolate, profiles, generator, processor); |
| 312 profiles->StartProfiling("", false); | 312 profiles->StartProfiling("", false); |
| 313 processor->Start(); | 313 processor->Start(); |
| 314 ProfilerListener profiler_listener(isolate); | 314 ProfilerListener profiler_listener(isolate); |
| 315 isolate->code_event_dispatcher()->AddListener(&profiler_listener); | 315 isolate->code_event_dispatcher()->AddListener(&profiler_listener); |
| 316 profiler_listener.AddObserver(&profiler); | 316 profiler_listener.AddObserver(&profiler); |
| 317 | 317 |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 CHECK(func->shared()); | 1070 CHECK(func->shared()); |
| 1071 CHECK(func->shared()->abstract_code()); | 1071 CHECK(func->shared()->abstract_code()); |
| 1072 CHECK(!optimize || func->IsOptimized() || | 1072 CHECK(!optimize || func->IsOptimized() || |
| 1073 !CcTest::i_isolate()->use_crankshaft()); | 1073 !CcTest::i_isolate()->use_crankshaft()); |
| 1074 i::AbstractCode* code = func->abstract_code(); | 1074 i::AbstractCode* code = func->abstract_code(); |
| 1075 CHECK(code); | 1075 CHECK(code); |
| 1076 i::Address code_address = code->instruction_start(); | 1076 i::Address code_address = code->instruction_start(); |
| 1077 CHECK(code_address); | 1077 CHECK(code_address); |
| 1078 | 1078 |
| 1079 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); | 1079 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); |
| 1080 ProfileGenerator* generator = new ProfileGenerator(isolate, profiles); | 1080 ProfileGenerator* generator = new ProfileGenerator(profiles); |
| 1081 ProfilerEventsProcessor* processor = | 1081 ProfilerEventsProcessor* processor = |
| 1082 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, | 1082 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, |
| 1083 v8::base::TimeDelta::FromMicroseconds(100)); | 1083 v8::base::TimeDelta::FromMicroseconds(100)); |
| 1084 CpuProfiler profiler(isolate, profiles, generator, processor); | 1084 CpuProfiler profiler(isolate, profiles, generator, processor); |
| 1085 profiles->StartProfiling("", false); | 1085 profiles->StartProfiling("", false); |
| 1086 processor->Start(); | 1086 processor->Start(); |
| 1087 ProfilerListener profiler_listener(isolate); | 1087 ProfilerListener profiler_listener(isolate); |
| 1088 isolate->code_event_dispatcher()->AddListener(&profiler_listener); | 1088 isolate->code_event_dispatcher()->AddListener(&profiler_listener); |
| 1089 profiler_listener.AddObserver(&profiler); | 1089 profiler_listener.AddObserver(&profiler); |
| 1090 | 1090 |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2181 printf("Profile JSON: %s\n", profile_json.c_str()); | 2181 printf("Profile JSON: %s\n", profile_json.c_str()); |
| 2182 std::string code = profile_checker + profile_json + ")"; | 2182 std::string code = profile_checker + profile_json + ")"; |
| 2183 v8::Local<v8::Value> result = | 2183 v8::Local<v8::Value> result = |
| 2184 CompileRunChecked(CcTest::isolate(), code.c_str()); | 2184 CompileRunChecked(CcTest::isolate(), code.c_str()); |
| 2185 v8::String::Utf8Value value(result); | 2185 v8::String::Utf8Value value(result); |
| 2186 printf("Check result: %*s\n", value.length(), *value); | 2186 printf("Check result: %*s\n", value.length(), *value); |
| 2187 CHECK_EQ(0, value.length()); | 2187 CHECK_EQ(0, value.length()); |
| 2188 | 2188 |
| 2189 i::V8::SetPlatformForTesting(old_platform); | 2189 i::V8::SetPlatformForTesting(old_platform); |
| 2190 } | 2190 } |
| OLD | NEW |