| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9236332 commit ab00559
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ | |||
| 11 | 11 | #define V8_MAJOR_VERSION 6 | |
| 12 | 12 | #define V8_MINOR_VERSION 2 | |
| 13 | 13 | #define V8_BUILD_NUMBER 414 | |
| 14 | - #define V8_PATCH_LEVEL 53 | ||
| 14 | + #define V8_PATCH_LEVEL 54 | ||
| 15 | 15 | ||
| 16 | 16 | // Use 1 for candidates and 0 otherwise. | |
| 17 | 17 | // (Boolean macro values are not supported by all preprocessors.) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -226,11 +226,18 @@ void ProfilerListener::RecordInliningInfo(CodeEntry* entry, | |||
| 226 | 226 | SharedFunctionInfo* shared_info = SharedFunctionInfo::cast( | |
| 227 | 227 | deopt_input_data->LiteralArray()->get(shared_info_id)); | |
| 228 | 228 | if (!depth++) continue; // Skip the current function itself. | |
| 229 | - CodeEntry* inline_entry = new CodeEntry( | ||
| 230 | - entry->tag(), GetFunctionName(shared_info->DebugName()), | ||
| 231 | - CodeEntry::kEmptyNamePrefix, entry->resource_name(), | ||
| 232 | - CpuProfileNode::kNoLineNumberInfo, | ||
| 233 | - CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | ||
| 229 | + const char* resource_name = | ||
| 230 | + (shared_info->script()->IsScript() && | ||
| 231 | + Script::cast(shared_info->script())->name()->IsName()) | ||
| 232 | + ? GetName(Name::cast(Script::cast(shared_info->script())->name())) | ||
| 233 | + : CodeEntry::kEmptyResourceName; | ||
| 234 | + | ||
| 235 | + CodeEntry* inline_entry = | ||
| 236 | + new CodeEntry(entry->tag(), GetFunctionName(shared_info->DebugName()), | ||
| 237 | + CodeEntry::kEmptyNamePrefix, resource_name, | ||
| 238 | + CpuProfileNode::kNoLineNumberInfo, | ||
| 239 | + CpuProfileNode::kNoColumnNumberInfo, nullptr, | ||
| 240 | + code->instruction_start()); | ||
| 234 | 241 | inline_entry->FillFunctionInfo(shared_info); | |
| 235 | 242 | inline_stack.push_back(inline_entry); | |
| 236 | 243 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1745,6 +1745,85 @@ TEST(FunctionDetails) { | |||
| 1745 | 1745 | script_a->GetUnboundScript()->GetId(), 5, 14); | |
| 1746 | 1746 | } | |
| 1747 | 1747 | ||
| 1748 | + TEST(FunctionDetailsInlining) { | ||
| 1749 | + if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | ||
| 1750 | + i::FLAG_allow_natives_syntax = true; | ||
| 1751 | + v8::HandleScope scope(CcTest::isolate()); | ||
| 1752 | + v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | ||
| 1753 | + v8::Context::Scope context_scope(env); | ||
| 1754 | + ProfilerHelper helper(env); | ||
| 1755 | + | ||
| 1756 | + // alpha is in a_script, beta in b_script. beta is | ||
| 1757 | + // inlined in alpha, but it should be attributed to b_script. | ||
| 1758 | + | ||
| 1759 | + v8::Local<v8::Script> script_b = CompileWithOrigin( | ||
| 1760 | + "function beta(k) {\n" | ||
| 1761 | + " let sum = 2;\n" | ||
| 1762 | + " for(let i = 0; i < k; i ++) {\n" | ||
| 1763 | + " sum += i;\n" | ||
| 1764 | + " sum = sum + 'a';\n" | ||
| 1765 | + " }\n" | ||
| 1766 | + " return sum;\n" | ||
| 1767 | + "}\n" | ||
| 1768 | + "\n", | ||
| 1769 | + "script_b"); | ||
| 1770 | + | ||
| 1771 | + v8::Local<v8::Script> script_a = CompileWithOrigin( | ||
| 1772 | + "function alpha(p) {\n" | ||
| 1773 | + " let res = beta(p);\n" | ||
| 1774 | + " res = res + res;\n" | ||
| 1775 | + " return res;\n" | ||
| 1776 | + "}\n" | ||
| 1777 | + "let p = 2;\n" | ||
| 1778 | + "\n" | ||
| 1779 | + "\n" | ||
| 1780 | + "// Warm up before profiling or the inlining doesn't happen.\n" | ||
| 1781 | + "p = alpha(p);\n" | ||
| 1782 | + "p = alpha(p);\n" | ||
| 1783 | + "%OptimizeFunctionOnNextCall(alpha);\n" | ||
| 1784 | + "p = alpha(p);\n" | ||
| 1785 | + "\n" | ||
| 1786 | + "\n" | ||
| 1787 | + "startProfiling();\n" | ||
| 1788 | + "for(let i = 0; i < 10000; i++) {\n" | ||
| 1789 | + " p = alpha(p);\n" | ||
| 1790 | + "}\n" | ||
| 1791 | + "stopProfiling();\n" | ||
| 1792 | + "\n" | ||
| 1793 | + "\n", | ||
| 1794 | + "script_a"); | ||
| 1795 | + | ||
| 1796 | + script_b->Run(env).ToLocalChecked(); | ||
| 1797 | + script_a->Run(env).ToLocalChecked(); | ||
| 1798 | + | ||
| 1799 | + const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; | ||
| 1800 | + const v8::CpuProfileNode* current = profile->GetTopDownRoot(); | ||
| 1801 | + reinterpret_cast<ProfileNode*>(const_cast<v8::CpuProfileNode*>(current)) | ||
| 1802 | + ->Print(0); | ||
| 1803 | + // The tree should look like this: | ||
| 1804 | + // 0 (root) 0 #1 | ||
| 1805 | + // 5 (program) 0 #6 | ||
| 1806 | + // 2 14 #2 script_a:1 | ||
| 1807 | + // ;;; deopted at script_id: 14 position: 299 with reason 'Insufficient | ||
| 1808 | + // type feedback for call'. | ||
| 1809 | + // 1 alpha 14 #4 script_a:1 | ||
| 1810 | + // 9 beta 13 #5 script_b:0 | ||
| 1811 | + // 0 startProfiling 0 #3 | ||
| 1812 | + | ||
| 1813 | + const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | ||
| 1814 | + const v8::CpuProfileNode* script = GetChild(env, root, ""); | ||
| 1815 | + CheckFunctionDetails(env->GetIsolate(), script, "", "script_a", | ||
| 1816 | + script_a->GetUnboundScript()->GetId(), 1, 1); | ||
| 1817 | + const v8::CpuProfileNode* alpha = FindChild(env, script, "alpha"); | ||
| 1818 | + // Return early if profiling didn't sample alpha. | ||
| 1819 | + if (!alpha) return; | ||
| 1820 | + CheckFunctionDetails(env->GetIsolate(), alpha, "alpha", "script_a", | ||
| 1821 | + script_a->GetUnboundScript()->GetId(), 1, 15); | ||
| 1822 | + const v8::CpuProfileNode* beta = FindChild(env, alpha, "beta"); | ||
| 1823 | + if (!beta) return; | ||
| 1824 | + CheckFunctionDetails(env->GetIsolate(), beta, "beta", "script_b", | ||
| 1825 | + script_b->GetUnboundScript()->GetId(), 0, 0); | ||
| 1826 | + } | ||
| 1748 | 1827 | ||
| 1749 | 1828 | TEST(DontStopOnFinishedProfileDelete) { | |
| 1750 | 1829 | v8::HandleScope scope(CcTest::isolate()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments