OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler.h" | 5 #include "src/compiler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/ast/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 static bool CompileBaselineCode(CompilationInfo* info) { | 847 static bool CompileBaselineCode(CompilationInfo* info) { |
848 DCHECK(AllowCompilation::IsAllowed(info->isolate())); | 848 DCHECK(AllowCompilation::IsAllowed(info->isolate())); |
849 if (!Compiler::Analyze(info->parse_info()) || !GenerateBaselineCode(info)) { | 849 if (!Compiler::Analyze(info->parse_info()) || !GenerateBaselineCode(info)) { |
850 Isolate* isolate = info->isolate(); | 850 Isolate* isolate = info->isolate(); |
851 if (!isolate->has_pending_exception()) isolate->StackOverflow(); | 851 if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
852 return false; | 852 return false; |
853 } | 853 } |
854 return true; | 854 return true; |
855 } | 855 } |
856 | 856 |
| 857 static void InstallBaselineCompilationResult(CompilationInfo* info, |
| 858 Handle<SharedFunctionInfo> shared, |
| 859 Handle<ScopeInfo> scope_info) { |
| 860 // Assert that we are not overwriting (possibly patched) debug code. |
| 861 DCHECK(!shared->HasDebugCode()); |
| 862 DCHECK(!info->code().is_null()); |
| 863 shared->ReplaceCode(*info->code()); |
| 864 shared->set_scope_info(*scope_info); |
| 865 shared->set_feedback_vector(*info->feedback_vector()); |
| 866 if (info->has_bytecode_array()) { |
| 867 DCHECK(!shared->HasBytecodeArray()); // Only compiled once. |
| 868 shared->set_bytecode_array(*info->bytecode_array()); |
| 869 } |
| 870 } |
857 | 871 |
858 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( | 872 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( |
859 CompilationInfo* info) { | 873 CompilationInfo* info) { |
860 VMState<COMPILER> state(info->isolate()); | 874 VMState<COMPILER> state(info->isolate()); |
861 PostponeInterruptsScope postpone(info->isolate()); | 875 PostponeInterruptsScope postpone(info->isolate()); |
862 | 876 |
863 // Parse and update CompilationInfo with the results. | 877 // Parse and update CompilationInfo with the results. |
864 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); | 878 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); |
865 Handle<SharedFunctionInfo> shared = info->shared_info(); | 879 Handle<SharedFunctionInfo> shared = info->shared_info(); |
866 FunctionLiteral* lit = info->literal(); | 880 FunctionLiteral* lit = info->literal(); |
867 DCHECK_EQ(shared->language_mode(), lit->language_mode()); | 881 DCHECK_EQ(shared->language_mode(), lit->language_mode()); |
868 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 882 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
869 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); | 883 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); |
870 | 884 |
871 // Compile either unoptimized code or bytecode for the interpreter. | 885 // Compile either unoptimized code or bytecode for the interpreter. |
872 if (!CompileBaselineCode(info)) return MaybeHandle<Code>(); | 886 if (!CompileBaselineCode(info)) return MaybeHandle<Code>(); |
873 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); | 887 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); |
874 | 888 |
875 // Update the shared function info with the scope info. Allocating the | 889 // Update the shared function info with the scope info. Allocating the |
876 // ScopeInfo object may cause a GC. | 890 // ScopeInfo object may cause a GC. |
877 Handle<ScopeInfo> scope_info = | 891 Handle<ScopeInfo> scope_info = |
878 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); | 892 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); |
879 shared->set_scope_info(*scope_info); | |
880 | 893 |
881 // Update the code and feedback vector for the shared function info. | 894 // Install compilation result on the shared function info |
882 shared->ReplaceCode(*info->code()); | 895 InstallBaselineCompilationResult(info, shared, scope_info); |
883 shared->set_feedback_vector(*info->feedback_vector()); | |
884 if (info->has_bytecode_array()) { | |
885 DCHECK(!shared->HasBytecodeArray()); // Only compiled once. | |
886 shared->set_bytecode_array(*info->bytecode_array()); | |
887 } | |
888 | 896 |
889 return info->code(); | 897 return info->code(); |
890 } | 898 } |
891 | 899 |
892 | 900 |
893 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( | 901 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( |
894 Handle<JSFunction> function, BailoutId osr_ast_id) { | 902 Handle<JSFunction> function, BailoutId osr_ast_id) { |
895 Handle<SharedFunctionInfo> shared(function->shared()); | 903 Handle<SharedFunctionInfo> shared(function->shared()); |
896 DisallowHeapAllocation no_gc; | 904 DisallowHeapAllocation no_gc; |
897 CodeAndLiterals cached = shared->SearchOptimizedCodeMap( | 905 CodeAndLiterals cached = shared->SearchOptimizedCodeMap( |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal()); | 1377 LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal()); |
1370 if (!CompileUnoptimizedCode(&info)) return; | 1378 if (!CompileUnoptimizedCode(&info)) return; |
1371 if (info.has_shared_info()) { | 1379 if (info.has_shared_info()) { |
1372 Handle<ScopeInfo> scope_info = | 1380 Handle<ScopeInfo> scope_info = |
1373 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); | 1381 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); |
1374 info.shared_info()->set_scope_info(*scope_info); | 1382 info.shared_info()->set_scope_info(*scope_info); |
1375 } | 1383 } |
1376 tracker.RecordRootFunctionInfo(info.code()); | 1384 tracker.RecordRootFunctionInfo(info.code()); |
1377 } | 1385 } |
1378 | 1386 |
| 1387 static Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral( |
| 1388 Isolate* isolate, FunctionLiteral* literal, Handle<Script> script) { |
| 1389 Handle<Code> code = isolate->builtins()->CompileLazy(); |
| 1390 Handle<ScopeInfo> scope_info = handle(ScopeInfo::Empty(isolate)); |
| 1391 Handle<SharedFunctionInfo> result = isolate->factory()->NewSharedFunctionInfo( |
| 1392 literal->name(), literal->materialized_literal_count(), literal->kind(), |
| 1393 code, scope_info); |
| 1394 SharedFunctionInfo::InitFromFunctionLiteral(result, literal); |
| 1395 SharedFunctionInfo::SetScript(result, script); |
| 1396 return result; |
| 1397 } |
1379 | 1398 |
1380 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { | 1399 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { |
1381 Isolate* isolate = info->isolate(); | 1400 Isolate* isolate = info->isolate(); |
1382 TimerEventScope<TimerEventCompileCode> timer(isolate); | 1401 TimerEventScope<TimerEventCompileCode> timer(isolate); |
1383 TRACE_EVENT0("v8", "V8.CompileCode"); | 1402 TRACE_EVENT0("v8", "V8.CompileCode"); |
1384 PostponeInterruptsScope postpone(isolate); | 1403 PostponeInterruptsScope postpone(isolate); |
1385 DCHECK(!isolate->native_context().is_null()); | 1404 DCHECK(!isolate->native_context().is_null()); |
1386 ParseInfo* parse_info = info->parse_info(); | 1405 ParseInfo* parse_info = info->parse_info(); |
1387 Handle<Script> script = parse_info->script(); | 1406 Handle<Script> script = parse_info->script(); |
1388 | 1407 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 | 1457 |
1439 // Measure how long it takes to do the compilation; only take the | 1458 // Measure how long it takes to do the compilation; only take the |
1440 // rest of the function into account to avoid overlap with the | 1459 // rest of the function into account to avoid overlap with the |
1441 // parsing statistics. | 1460 // parsing statistics. |
1442 HistogramTimer* rate = info->is_eval() | 1461 HistogramTimer* rate = info->is_eval() |
1443 ? info->isolate()->counters()->compile_eval() | 1462 ? info->isolate()->counters()->compile_eval() |
1444 : info->isolate()->counters()->compile(); | 1463 : info->isolate()->counters()->compile(); |
1445 HistogramTimerScope timer(rate); | 1464 HistogramTimerScope timer(rate); |
1446 TRACE_EVENT0("v8", info->is_eval() ? "V8.CompileEval" : "V8.Compile"); | 1465 TRACE_EVENT0("v8", info->is_eval() ? "V8.CompileEval" : "V8.Compile"); |
1447 | 1466 |
| 1467 // Allocate a shared function info object. |
| 1468 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
| 1469 result = NewSharedFunctionInfoForLiteral(isolate, lit, script); |
| 1470 result->set_is_toplevel(true); |
| 1471 if (info->is_eval()) { |
| 1472 // Eval scripts cannot be (re-)compiled without context. |
| 1473 result->set_allows_lazy_compilation_without_context(false); |
| 1474 } |
| 1475 |
1448 // Compile the code. | 1476 // Compile the code. |
1449 if (!CompileBaselineCode(info)) { | 1477 if (!CompileBaselineCode(info)) { |
1450 return Handle<SharedFunctionInfo>::null(); | 1478 return Handle<SharedFunctionInfo>::null(); |
1451 } | 1479 } |
1452 | 1480 |
1453 // Allocate function. | 1481 // Install compilation result on the shared function info |
1454 DCHECK(!info->code().is_null()); | 1482 Handle<ScopeInfo> scope_info = |
1455 result = isolate->factory()->NewSharedFunctionInfo( | 1483 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); |
1456 lit->name(), lit->materialized_literal_count(), lit->kind(), | 1484 InstallBaselineCompilationResult(info, result, scope_info); |
1457 info->code(), | |
1458 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()), | |
1459 info->feedback_vector()); | |
1460 if (info->has_bytecode_array()) { | |
1461 DCHECK(!result->HasBytecodeArray()); // Only compiled once. | |
1462 result->set_bytecode_array(*info->bytecode_array()); | |
1463 } | |
1464 | |
1465 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | |
1466 SharedFunctionInfo::InitFromFunctionLiteral(result, lit); | |
1467 SharedFunctionInfo::SetScript(result, script); | |
1468 result->set_is_toplevel(true); | |
1469 if (info->is_eval()) { | |
1470 // Eval scripts cannot be (re-)compiled without context. | |
1471 result->set_allows_lazy_compilation_without_context(false); | |
1472 } | |
1473 | 1485 |
1474 Handle<String> script_name = | 1486 Handle<String> script_name = |
1475 script->name()->IsString() | 1487 script->name()->IsString() |
1476 ? Handle<String>(String::cast(script->name())) | 1488 ? Handle<String>(String::cast(script->name())) |
1477 : isolate->factory()->empty_string(); | 1489 : isolate->factory()->empty_string(); |
1478 Logger::LogEventsAndTags log_tag = info->is_eval() | 1490 Logger::LogEventsAndTags log_tag = info->is_eval() |
1479 ? Logger::EVAL_TAG | 1491 ? Logger::EVAL_TAG |
1480 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); | 1492 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); |
1481 | 1493 |
1482 PROFILE(isolate, CodeCreateEvent(log_tag, *info->abstract_code(), *result, | 1494 PROFILE(isolate, CodeCreateEvent(log_tag, *info->abstract_code(), *result, |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 // compiled, continue to decide whether to eagerly compile. | 1749 // compiled, continue to decide whether to eagerly compile. |
1738 // Carry on if we are compiling eager to obtain code for debugging, | 1750 // Carry on if we are compiling eager to obtain code for debugging, |
1739 // unless we already have code with debut break slots. | 1751 // unless we already have code with debut break slots. |
1740 Handle<SharedFunctionInfo> existing; | 1752 Handle<SharedFunctionInfo> existing; |
1741 if (maybe_existing.ToHandle(&existing) && existing->is_compiled()) { | 1753 if (maybe_existing.ToHandle(&existing) && existing->is_compiled()) { |
1742 if (!outer_info->is_debug() || existing->HasDebugCode()) { | 1754 if (!outer_info->is_debug() || existing->HasDebugCode()) { |
1743 return existing; | 1755 return existing; |
1744 } | 1756 } |
1745 } | 1757 } |
1746 | 1758 |
| 1759 // Allocate a shared function info object. |
| 1760 Handle<SharedFunctionInfo> result; |
| 1761 if (!maybe_existing.ToHandle(&result)) { |
| 1762 result = NewSharedFunctionInfoForLiteral(isolate, literal, script); |
| 1763 result->set_is_toplevel(false); |
| 1764 } |
| 1765 |
1747 Zone zone; | 1766 Zone zone; |
1748 ParseInfo parse_info(&zone, script); | 1767 ParseInfo parse_info(&zone, script); |
1749 CompilationInfo info(&parse_info); | 1768 CompilationInfo info(&parse_info); |
1750 parse_info.set_literal(literal); | 1769 parse_info.set_literal(literal); |
1751 parse_info.set_scope(literal->scope()); | 1770 parse_info.set_scope(literal->scope()); |
1752 parse_info.set_language_mode(literal->scope()->language_mode()); | 1771 parse_info.set_language_mode(literal->scope()->language_mode()); |
1753 if (outer_info->will_serialize()) info.PrepareForSerializing(); | 1772 if (outer_info->will_serialize()) info.PrepareForSerializing(); |
1754 if (outer_info->is_first_compile()) info.MarkAsFirstCompile(); | 1773 if (outer_info->is_first_compile()) info.MarkAsFirstCompile(); |
1755 if (outer_info->is_debug()) info.MarkAsDebug(); | 1774 if (outer_info->is_debug()) info.MarkAsDebug(); |
1756 | 1775 |
(...skipping 15 matching lines...) Expand all Loading... |
1772 (!info.is_debug() || allow_lazy_without_ctx); | 1791 (!info.is_debug() || allow_lazy_without_ctx); |
1773 | 1792 |
1774 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); | 1793 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); |
1775 | 1794 |
1776 // Consider compiling eagerly when targeting the code cache. | 1795 // Consider compiling eagerly when targeting the code cache. |
1777 lazy &= !(FLAG_serialize_eager && info.will_serialize()); | 1796 lazy &= !(FLAG_serialize_eager && info.will_serialize()); |
1778 | 1797 |
1779 // Generate code | 1798 // Generate code |
1780 TimerEventScope<TimerEventCompileCode> timer(isolate); | 1799 TimerEventScope<TimerEventCompileCode> timer(isolate); |
1781 TRACE_EVENT0("v8", "V8.CompileCode"); | 1800 TRACE_EVENT0("v8", "V8.CompileCode"); |
1782 Handle<ScopeInfo> scope_info; | |
1783 if (lazy) { | 1801 if (lazy) { |
1784 Handle<Code> code = isolate->builtins()->CompileLazy(); | 1802 info.SetCode(isolate->builtins()->CompileLazy()); |
1785 info.SetCode(code); | |
1786 // There's no need in theory for a lazy-compiled function to have a type | |
1787 // feedback vector, but some parts of the system expect all | |
1788 // SharedFunctionInfo instances to have one. The size of the vector depends | |
1789 // on how many feedback-needing nodes are in the tree, and when lazily | |
1790 // parsing we might not know that, if this function was never parsed before. | |
1791 // In that case the vector will be replaced the next time MakeCode is | |
1792 // called. | |
1793 info.EnsureFeedbackVector(); | |
1794 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); | |
1795 } else if (Renumber(info.parse_info()) && GenerateBaselineCode(&info)) { | 1803 } else if (Renumber(info.parse_info()) && GenerateBaselineCode(&info)) { |
1796 // Code generation will ensure that the feedback vector is present and | 1804 // Code generation will ensure that the feedback vector is present and |
1797 // appropriately sized. | 1805 // appropriately sized. |
1798 DCHECK(!info.code().is_null()); | 1806 DCHECK(!info.code().is_null()); |
1799 scope_info = ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); | 1807 Handle<ScopeInfo> scope_info = |
| 1808 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); |
1800 if (literal->should_eager_compile() && | 1809 if (literal->should_eager_compile() && |
1801 literal->should_be_used_once_hint()) { | 1810 literal->should_be_used_once_hint()) { |
1802 info.code()->MarkToBeExecutedOnce(isolate); | 1811 info.code()->MarkToBeExecutedOnce(isolate); |
1803 } | 1812 } |
| 1813 // Install compilation result on the shared function info. |
| 1814 InstallBaselineCompilationResult(&info, result, scope_info); |
1804 } else { | 1815 } else { |
1805 return Handle<SharedFunctionInfo>::null(); | 1816 return Handle<SharedFunctionInfo>::null(); |
1806 } | 1817 } |
1807 | 1818 |
1808 if (maybe_existing.is_null()) { | 1819 if (maybe_existing.is_null()) { |
1809 // Create a shared function info object. | |
1810 Handle<SharedFunctionInfo> result = | |
1811 isolate->factory()->NewSharedFunctionInfo( | |
1812 literal->name(), literal->materialized_literal_count(), | |
1813 literal->kind(), info.code(), scope_info, info.feedback_vector()); | |
1814 if (info.has_bytecode_array()) { | |
1815 DCHECK(!result->HasBytecodeArray()); // Only compiled once. | |
1816 result->set_bytecode_array(*info.bytecode_array()); | |
1817 } | |
1818 | |
1819 SharedFunctionInfo::InitFromFunctionLiteral(result, literal); | |
1820 SharedFunctionInfo::SetScript(result, script); | |
1821 result->set_is_toplevel(false); | |
1822 // If the outer function has been compiled before, we cannot be sure that | 1820 // If the outer function has been compiled before, we cannot be sure that |
1823 // shared function info for this function literal has been created for the | 1821 // shared function info for this function literal has been created for the |
1824 // first time. It may have already been compiled previously. | 1822 // first time. It may have already been compiled previously. |
1825 result->set_never_compiled(outer_info->is_first_compile() && lazy); | 1823 result->set_never_compiled(outer_info->is_first_compile() && lazy); |
1826 | 1824 |
1827 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); | 1825 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
1828 result->set_allows_lazy_compilation(literal->AllowsLazyCompilation()); | 1826 result->set_allows_lazy_compilation(literal->AllowsLazyCompilation()); |
1829 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); | 1827 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); |
1830 | 1828 |
1831 // Set the expected number of properties for instances and return | 1829 // Set the expected number of properties for instances and return |
1832 // the resulting function. | 1830 // the resulting function. |
1833 SetExpectedNofPropertiesFromEstimate(result, | 1831 SetExpectedNofPropertiesFromEstimate(result, |
1834 literal->expected_property_count()); | 1832 literal->expected_property_count()); |
1835 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); | 1833 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); |
1836 return result; | |
1837 } else if (!lazy) { | |
1838 // Assert that we are not overwriting (possibly patched) debug code. | |
1839 DCHECK(!existing->HasDebugCode()); | |
1840 existing->ReplaceCode(*info.code()); | |
1841 existing->set_scope_info(*scope_info); | |
1842 existing->set_feedback_vector(*info.feedback_vector()); | |
1843 } | 1834 } |
1844 return existing; | 1835 |
| 1836 return result; |
1845 } | 1837 } |
1846 | 1838 |
1847 Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForNative( | 1839 Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForNative( |
1848 v8::Extension* extension, Handle<String> name) { | 1840 v8::Extension* extension, Handle<String> name) { |
1849 Isolate* isolate = name->GetIsolate(); | 1841 Isolate* isolate = name->GetIsolate(); |
1850 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 1842 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
1851 | 1843 |
1852 // Compute the function template for the native function. | 1844 // Compute the function template for the native function. |
1853 v8::Local<v8::FunctionTemplate> fun_template = | 1845 v8::Local<v8::FunctionTemplate> fun_template = |
1854 extension->GetNativeFunctionTemplate(v8_isolate, | 1846 extension->GetNativeFunctionTemplate(v8_isolate, |
1855 v8::Utils::ToLocal(name)); | 1847 v8::Utils::ToLocal(name)); |
1856 DCHECK(!fun_template.IsEmpty()); | 1848 DCHECK(!fun_template.IsEmpty()); |
1857 | 1849 |
1858 // Instantiate the function and create a shared function info from it. | 1850 // Instantiate the function and create a shared function info from it. |
1859 Handle<JSFunction> fun = Handle<JSFunction>::cast(Utils::OpenHandle( | 1851 Handle<JSFunction> fun = Handle<JSFunction>::cast(Utils::OpenHandle( |
1860 *fun_template->GetFunction(v8_isolate->GetCurrentContext()) | 1852 *fun_template->GetFunction(v8_isolate->GetCurrentContext()) |
1861 .ToLocalChecked())); | 1853 .ToLocalChecked())); |
1862 const int literals = fun->NumberOfLiterals(); | 1854 const int literals = fun->NumberOfLiterals(); |
1863 Handle<Code> code = Handle<Code>(fun->shared()->code()); | 1855 Handle<Code> code = Handle<Code>(fun->shared()->code()); |
1864 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); | 1856 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); |
1865 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( | 1857 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( |
1866 name, literals, FunctionKind::kNormalFunction, code, | 1858 name, literals, FunctionKind::kNormalFunction, code, |
1867 Handle<ScopeInfo>(fun->shared()->scope_info()), | 1859 Handle<ScopeInfo>(fun->shared()->scope_info())); |
1868 Handle<TypeFeedbackVector>(fun->shared()->feedback_vector())); | |
1869 shared->set_construct_stub(*construct_stub); | 1860 shared->set_construct_stub(*construct_stub); |
| 1861 shared->set_feedback_vector(fun->shared()->feedback_vector()); |
1870 | 1862 |
1871 // Copy the function data to the shared function info. | 1863 // Copy the function data to the shared function info. |
1872 shared->set_function_data(fun->shared()->function_data()); | 1864 shared->set_function_data(fun->shared()->function_data()); |
1873 int parameters = fun->shared()->internal_formal_parameter_count(); | 1865 int parameters = fun->shared()->internal_formal_parameter_count(); |
1874 shared->set_internal_formal_parameter_count(parameters); | 1866 shared->set_internal_formal_parameter_count(parameters); |
1875 | 1867 |
1876 return shared; | 1868 return shared; |
1877 } | 1869 } |
1878 | 1870 |
1879 MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function, | 1871 MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 | 1964 |
1973 #if DEBUG | 1965 #if DEBUG |
1974 void CompilationInfo::PrintAstForTesting() { | 1966 void CompilationInfo::PrintAstForTesting() { |
1975 PrintF("--- Source from AST ---\n%s\n", | 1967 PrintF("--- Source from AST ---\n%s\n", |
1976 PrettyPrinter(isolate()).PrintProgram(literal())); | 1968 PrettyPrinter(isolate()).PrintProgram(literal())); |
1977 } | 1969 } |
1978 #endif | 1970 #endif |
1979 | 1971 |
1980 } // namespace internal | 1972 } // namespace internal |
1981 } // namespace v8 | 1973 } // namespace v8 |
OLD | NEW |