| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 return v8::Local<v8::Function>::Cast( | 56 return v8::Local<v8::Function>::Cast( |
| 57 env->Global()->Get(env, v8_str(name)).ToLocalChecked()); | 57 env->Global()->Get(env, v8_str(name)).ToLocalChecked()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 static size_t offset(const char* src, const char* substring) { | 60 static size_t offset(const char* src, const char* substring) { |
| 61 const char* it = strstr(src, substring); | 61 const char* it = strstr(src, substring); |
| 62 CHECK(it); | 62 CHECK(it); |
| 63 return static_cast<size_t>(it - src); | 63 return static_cast<size_t>(it - src); |
| 64 } | 64 } |
| 65 | 65 |
| 66 static const char* reason(const i::Deoptimizer::DeoptReason reason) { | 66 static const char* reason(const i::DeoptimizeReason reason) { |
| 67 return i::Deoptimizer::GetDeoptReason(reason); | 67 return i::DeoptimizeReasonToString(reason); |
| 68 } | 68 } |
| 69 | 69 |
| 70 TEST(StartStop) { | 70 TEST(StartStop) { |
| 71 CpuProfilesCollection profiles(CcTest::i_isolate()); | 71 CpuProfilesCollection profiles(CcTest::i_isolate()); |
| 72 ProfileGenerator generator(&profiles); | 72 ProfileGenerator generator(&profiles); |
| 73 std::unique_ptr<ProfilerEventsProcessor> processor( | 73 std::unique_ptr<ProfilerEventsProcessor> processor( |
| 74 new ProfilerEventsProcessor(CcTest::i_isolate(), &generator, | 74 new ProfilerEventsProcessor(CcTest::i_isolate(), &generator, |
| 75 v8::base::TimeDelta::FromMicroseconds(100))); | 75 v8::base::TimeDelta::FromMicroseconds(100))); |
| 76 processor->Start(); | 76 processor->Start(); |
| 77 processor->StopSynchronously(); | 77 processor->StopSynchronously(); |
| (...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 ;;; deopted at script_id: 29 position: 108 with reason 'not a | 1846 ;;; deopted at script_id: 29 position: 108 with reason 'not a |
| 1847 heap number'. | 1847 heap number'. |
| 1848 0 opt_function1 30 #5 | 1848 0 opt_function1 30 #5 |
| 1849 1 opt_function1 30 #6 | 1849 1 opt_function1 30 #6 |
| 1850 ;;; deopted at script_id: 30 position: 108 with reason 'lost | 1850 ;;; deopted at script_id: 30 position: 108 with reason 'lost |
| 1851 precision or NaN'. | 1851 precision or NaN'. |
| 1852 */ | 1852 */ |
| 1853 | 1853 |
| 1854 { | 1854 { |
| 1855 const char* branch[] = {"", "opt_function0", "opt_function0"}; | 1855 const char* branch[] = {"", "opt_function0", "opt_function0"}; |
| 1856 CHECK_EQ(reason(i::Deoptimizer::kNotAHeapNumber), | 1856 CHECK_EQ(reason(i::DeoptimizeReason::kNotAHeapNumber), |
| 1857 GetBranchDeoptReason(env, iprofile, branch, arraysize(branch))); | 1857 GetBranchDeoptReason(env, iprofile, branch, arraysize(branch))); |
| 1858 } | 1858 } |
| 1859 { | 1859 { |
| 1860 const char* branch[] = {"", "opt_function1", "opt_function1"}; | 1860 const char* branch[] = {"", "opt_function1", "opt_function1"}; |
| 1861 const char* deopt_reason = | 1861 const char* deopt_reason = |
| 1862 GetBranchDeoptReason(env, iprofile, branch, arraysize(branch)); | 1862 GetBranchDeoptReason(env, iprofile, branch, arraysize(branch)); |
| 1863 if (deopt_reason != reason(i::Deoptimizer::kNaN) && | 1863 if (deopt_reason != reason(i::DeoptimizeReason::kNaN) && |
| 1864 deopt_reason != reason(i::Deoptimizer::kLostPrecisionOrNaN)) { | 1864 deopt_reason != reason(i::DeoptimizeReason::kLostPrecisionOrNaN)) { |
| 1865 FATAL(deopt_reason); | 1865 FATAL(deopt_reason); |
| 1866 } | 1866 } |
| 1867 } | 1867 } |
| 1868 { | 1868 { |
| 1869 const char* branch[] = {"", "opt_function2", "opt_function2"}; | 1869 const char* branch[] = {"", "opt_function2", "opt_function2"}; |
| 1870 CHECK_EQ(reason(i::Deoptimizer::kDivisionByZero), | 1870 CHECK_EQ(reason(i::DeoptimizeReason::kDivisionByZero), |
| 1871 GetBranchDeoptReason(env, iprofile, branch, arraysize(branch))); | 1871 GetBranchDeoptReason(env, iprofile, branch, arraysize(branch))); |
| 1872 } | 1872 } |
| 1873 iprofiler->DeleteProfile(iprofile); | 1873 iprofiler->DeleteProfile(iprofile); |
| 1874 } | 1874 } |
| 1875 | 1875 |
| 1876 | 1876 |
| 1877 TEST(SourceLocation) { | 1877 TEST(SourceLocation) { |
| 1878 i::FLAG_always_opt = true; | 1878 i::FLAG_always_opt = true; |
| 1879 i::FLAG_hydrogen_track_positions = true; | 1879 i::FLAG_hydrogen_track_positions = true; |
| 1880 LocalContext env; | 1880 LocalContext env; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); | 1950 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); |
| 1951 | 1951 |
| 1952 const char* branch[] = {"", "test"}; | 1952 const char* branch[] = {"", "test"}; |
| 1953 const ProfileNode* itest_node = | 1953 const ProfileNode* itest_node = |
| 1954 GetSimpleBranch(env, profile, branch, arraysize(branch)); | 1954 GetSimpleBranch(env, profile, branch, arraysize(branch)); |
| 1955 const std::vector<v8::CpuProfileDeoptInfo>& deopt_infos = | 1955 const std::vector<v8::CpuProfileDeoptInfo>& deopt_infos = |
| 1956 itest_node->deopt_infos(); | 1956 itest_node->deopt_infos(); |
| 1957 CHECK_EQ(1U, deopt_infos.size()); | 1957 CHECK_EQ(1U, deopt_infos.size()); |
| 1958 | 1958 |
| 1959 const v8::CpuProfileDeoptInfo& info = deopt_infos[0]; | 1959 const v8::CpuProfileDeoptInfo& info = deopt_infos[0]; |
| 1960 CHECK_EQ(reason(i::Deoptimizer::kNotAHeapNumber), info.deopt_reason); | 1960 CHECK_EQ(reason(i::DeoptimizeReason::kNotAHeapNumber), info.deopt_reason); |
| 1961 CHECK_EQ(2U, info.stack.size()); | 1961 CHECK_EQ(2U, info.stack.size()); |
| 1962 CHECK_EQ(inlined_script_id, info.stack[0].script_id); | 1962 CHECK_EQ(inlined_script_id, info.stack[0].script_id); |
| 1963 CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position); | 1963 CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position); |
| 1964 CHECK_EQ(script_id, info.stack[1].script_id); | 1964 CHECK_EQ(script_id, info.stack[1].script_id); |
| 1965 CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position); | 1965 CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position); |
| 1966 | 1966 |
| 1967 iprofiler->DeleteProfile(iprofile); | 1967 iprofiler->DeleteProfile(iprofile); |
| 1968 } | 1968 } |
| 1969 | 1969 |
| 1970 | 1970 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); | 2023 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); |
| 2024 | 2024 |
| 2025 const char* branch[] = {"", "test1"}; | 2025 const char* branch[] = {"", "test1"}; |
| 2026 const ProfileNode* itest_node = | 2026 const ProfileNode* itest_node = |
| 2027 GetSimpleBranch(env, profile, branch, arraysize(branch)); | 2027 GetSimpleBranch(env, profile, branch, arraysize(branch)); |
| 2028 const std::vector<v8::CpuProfileDeoptInfo>& deopt_infos = | 2028 const std::vector<v8::CpuProfileDeoptInfo>& deopt_infos = |
| 2029 itest_node->deopt_infos(); | 2029 itest_node->deopt_infos(); |
| 2030 CHECK_EQ(1U, deopt_infos.size()); | 2030 CHECK_EQ(1U, deopt_infos.size()); |
| 2031 | 2031 |
| 2032 const v8::CpuProfileDeoptInfo info = deopt_infos[0]; | 2032 const v8::CpuProfileDeoptInfo info = deopt_infos[0]; |
| 2033 CHECK_EQ(reason(i::Deoptimizer::kNotAHeapNumber), info.deopt_reason); | 2033 CHECK_EQ(reason(i::DeoptimizeReason::kNotAHeapNumber), info.deopt_reason); |
| 2034 CHECK_EQ(3U, info.stack.size()); | 2034 CHECK_EQ(3U, info.stack.size()); |
| 2035 CHECK_EQ(inlined_script_id, info.stack[0].script_id); | 2035 CHECK_EQ(inlined_script_id, info.stack[0].script_id); |
| 2036 CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position); | 2036 CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position); |
| 2037 CHECK_EQ(script_id, info.stack[1].script_id); | 2037 CHECK_EQ(script_id, info.stack[1].script_id); |
| 2038 CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position); | 2038 CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position); |
| 2039 CHECK_EQ(offset(source, "test2(left, right);"), info.stack[2].position); | 2039 CHECK_EQ(offset(source, "test2(left, right);"), info.stack[2].position); |
| 2040 | 2040 |
| 2041 iprofiler->DeleteProfile(iprofile); | 2041 iprofiler->DeleteProfile(iprofile); |
| 2042 } | 2042 } |
| 2043 | 2043 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 iprofile->Print(); | 2080 iprofile->Print(); |
| 2081 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); | 2081 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); |
| 2082 | 2082 |
| 2083 const char* branch[] = {"", "test"}; | 2083 const char* branch[] = {"", "test"}; |
| 2084 const ProfileNode* itest_node = | 2084 const ProfileNode* itest_node = |
| 2085 GetSimpleBranch(env, profile, branch, arraysize(branch)); | 2085 GetSimpleBranch(env, profile, branch, arraysize(branch)); |
| 2086 CHECK_EQ(0U, itest_node->deopt_infos().size()); | 2086 CHECK_EQ(0U, itest_node->deopt_infos().size()); |
| 2087 | 2087 |
| 2088 iprofiler->DeleteProfile(iprofile); | 2088 iprofiler->DeleteProfile(iprofile); |
| 2089 } | 2089 } |
| OLD | NEW |