| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 using i::SmartPointer; | 49 using i::SmartPointer; |
| 50 using i::Vector; | 50 using i::Vector; |
| 51 | 51 |
| 52 | 52 |
| 53 // Helper methods | 53 // Helper methods |
| 54 static v8::Local<v8::Function> GetFunction(v8::Context* env, const char* name) { | 54 static v8::Local<v8::Function> GetFunction(v8::Context* env, const char* name) { |
| 55 return v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str(name))); | 55 return v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str(name))); |
| 56 } | 56 } |
| 57 | 57 |
| 58 | 58 |
| 59 static int offset(const char* src, const char* substring) { | 59 static size_t offset(const char* src, const char* substring) { |
| 60 return static_cast<int>(strstr(src, substring) - src); | 60 const char* it = strstr(src, substring); |
| 61 CHECK(it); |
| 62 return static_cast<size_t>(it - src); |
| 61 } | 63 } |
| 62 | 64 |
| 63 | 65 |
| 64 static const char* reason(const i::Deoptimizer::DeoptReason reason) { | 66 static const char* reason(const i::Deoptimizer::DeoptReason reason) { |
| 65 return i::Deoptimizer::GetDeoptReason(reason); | 67 return i::Deoptimizer::GetDeoptReason(reason); |
| 66 } | 68 } |
| 67 | 69 |
| 68 | 70 |
| 69 TEST(StartStop) { | 71 TEST(StartStop) { |
| 70 i::Isolate* isolate = CcTest::i_isolate(); | 72 i::Isolate* isolate = CcTest::i_isolate(); |
| (...skipping 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 ;;; deopted at script_id: 29 position: 45 with reason 'not a | 1893 ;;; deopted at script_id: 29 position: 45 with reason 'not a |
| 1892 heap number'. | 1894 heap number'. |
| 1893 ;;; Inline point: script_id 30 position: 36. | 1895 ;;; Inline point: script_id 30 position: 36. |
| 1894 4 opt_function 29 #4 | 1896 4 opt_function 29 #4 |
| 1895 */ | 1897 */ |
| 1896 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); | 1898 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); |
| 1897 | 1899 |
| 1898 const char* branch[] = {"", "test"}; | 1900 const char* branch[] = {"", "test"}; |
| 1899 const ProfileNode* itest_node = | 1901 const ProfileNode* itest_node = |
| 1900 GetSimpleBranch(profile, branch, arraysize(branch)); | 1902 GetSimpleBranch(profile, branch, arraysize(branch)); |
| 1901 const std::vector<i::DeoptInfo>& deopt_infos = itest_node->deopt_infos(); | 1903 const std::vector<v8::CpuProfileDeoptInfo>& deopt_infos = |
| 1904 itest_node->deopt_infos(); |
| 1902 CHECK_EQ(1, deopt_infos.size()); | 1905 CHECK_EQ(1, deopt_infos.size()); |
| 1903 | 1906 |
| 1904 const i::DeoptInfo& info = deopt_infos[0]; | 1907 const v8::CpuProfileDeoptInfo& info = deopt_infos[0]; |
| 1905 CHECK_EQ(reason(i::Deoptimizer::kNotAHeapNumber), info.deopt_reason); | 1908 CHECK_EQ(reason(i::Deoptimizer::kNotAHeapNumber), info.deopt_reason); |
| 1906 CHECK_EQ(2, info.stack.size()); | 1909 CHECK_EQ(2, info.stack.size()); |
| 1907 CHECK_EQ(inlined_script_id, info.stack[0].script_id); | 1910 CHECK_EQ(inlined_script_id, info.stack[0].script_id); |
| 1908 CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position); | 1911 CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position); |
| 1909 CHECK_EQ(script_id, info.stack[1].script_id); | 1912 CHECK_EQ(script_id, info.stack[1].script_id); |
| 1910 CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position); | 1913 CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position); |
| 1911 | 1914 |
| 1912 iprofiler->DeleteProfile(iprofile); | 1915 iprofiler->DeleteProfile(iprofile); |
| 1913 } | 1916 } |
| 1914 | 1917 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 ;;; Inline point: script_id 30 position: 103. | 1966 ;;; Inline point: script_id 30 position: 103. |
| 1964 1 test2 30 #4 | 1967 1 test2 30 #4 |
| 1965 3 opt_function 29 #5 | 1968 3 opt_function 29 #5 |
| 1966 */ | 1969 */ |
| 1967 | 1970 |
| 1968 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); | 1971 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); |
| 1969 | 1972 |
| 1970 const char* branch[] = {"", "test1"}; | 1973 const char* branch[] = {"", "test1"}; |
| 1971 const ProfileNode* itest_node = | 1974 const ProfileNode* itest_node = |
| 1972 GetSimpleBranch(profile, branch, arraysize(branch)); | 1975 GetSimpleBranch(profile, branch, arraysize(branch)); |
| 1973 const std::vector<i::DeoptInfo>& deopt_infos = itest_node->deopt_infos(); | 1976 const std::vector<v8::CpuProfileDeoptInfo>& deopt_infos = |
| 1977 itest_node->deopt_infos(); |
| 1974 CHECK_EQ(1, deopt_infos.size()); | 1978 CHECK_EQ(1, deopt_infos.size()); |
| 1975 | 1979 |
| 1976 const i::DeoptInfo info = deopt_infos[0]; | 1980 const v8::CpuProfileDeoptInfo info = deopt_infos[0]; |
| 1977 CHECK_EQ(reason(i::Deoptimizer::kNotAHeapNumber), info.deopt_reason); | 1981 CHECK_EQ(reason(i::Deoptimizer::kNotAHeapNumber), info.deopt_reason); |
| 1978 CHECK_EQ(3, info.stack.size()); | 1982 CHECK_EQ(3, info.stack.size()); |
| 1979 CHECK_EQ(inlined_script_id, info.stack[0].script_id); | 1983 CHECK_EQ(inlined_script_id, info.stack[0].script_id); |
| 1980 CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position); | 1984 CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position); |
| 1981 CHECK_EQ(script_id, info.stack[1].script_id); | 1985 CHECK_EQ(script_id, info.stack[1].script_id); |
| 1982 CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position); | 1986 CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position); |
| 1983 CHECK_EQ(offset(source, "test2(left, right);"), info.stack[2].position); | 1987 CHECK_EQ(offset(source, "test2(left, right);"), info.stack[2].position); |
| 1984 | 1988 |
| 1985 iprofiler->DeleteProfile(iprofile); | 1989 iprofiler->DeleteProfile(iprofile); |
| 1986 } | 1990 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 iprofile->Print(); | 2028 iprofile->Print(); |
| 2025 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); | 2029 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); |
| 2026 | 2030 |
| 2027 const char* branch[] = {"", "test"}; | 2031 const char* branch[] = {"", "test"}; |
| 2028 const ProfileNode* itest_node = | 2032 const ProfileNode* itest_node = |
| 2029 GetSimpleBranch(profile, branch, arraysize(branch)); | 2033 GetSimpleBranch(profile, branch, arraysize(branch)); |
| 2030 CHECK_EQ(0, itest_node->deopt_infos().size()); | 2034 CHECK_EQ(0, itest_node->deopt_infos().size()); |
| 2031 | 2035 |
| 2032 iprofiler->DeleteProfile(iprofile); | 2036 iprofiler->DeleteProfile(iprofile); |
| 2033 } | 2037 } |
| OLD | NEW |