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