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 DCHECK(!info->code().is_null()); | |
861 shared->ReplaceCode(*info->code()); | |
862 shared->set_scope_info(*scope_info); | |
863 shared->set_feedback_vector(*info->feedback_vector()); | |
864 if (info->has_bytecode_array()) { | |
865 DCHECK(!shared->HasBytecodeArray()); // Only compiled once. | |
866 shared->set_bytecode_array(*info->bytecode_array()); | |
867 } | |
868 } | |
857 | 869 |
858 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( | 870 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( |
859 CompilationInfo* info) { | 871 CompilationInfo* info) { |
860 VMState<COMPILER> state(info->isolate()); | 872 VMState<COMPILER> state(info->isolate()); |
861 PostponeInterruptsScope postpone(info->isolate()); | 873 PostponeInterruptsScope postpone(info->isolate()); |
862 | 874 |
863 // Parse and update CompilationInfo with the results. | 875 // Parse and update CompilationInfo with the results. |
864 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); | 876 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); |
865 Handle<SharedFunctionInfo> shared = info->shared_info(); | 877 Handle<SharedFunctionInfo> shared = info->shared_info(); |
866 FunctionLiteral* lit = info->literal(); | 878 FunctionLiteral* lit = info->literal(); |
867 DCHECK_EQ(shared->language_mode(), lit->language_mode()); | 879 DCHECK_EQ(shared->language_mode(), lit->language_mode()); |
868 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 880 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
869 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); | 881 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); |
870 | 882 |
871 // Compile either unoptimized code or bytecode for the interpreter. | 883 // Compile either unoptimized code or bytecode for the interpreter. |
872 if (!CompileBaselineCode(info)) return MaybeHandle<Code>(); | 884 if (!CompileBaselineCode(info)) return MaybeHandle<Code>(); |
873 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); | 885 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); |
874 | 886 |
875 // Update the shared function info with the scope info. Allocating the | 887 // Update the shared function info with the scope info. Allocating the |
876 // ScopeInfo object may cause a GC. | 888 // ScopeInfo object may cause a GC. |
877 Handle<ScopeInfo> scope_info = | 889 Handle<ScopeInfo> scope_info = |
878 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); | 890 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); |
879 shared->set_scope_info(*scope_info); | |
880 | 891 |
881 // Update the code and feedback vector for the shared function info. | 892 // Install compilation result on the shared function info |
882 shared->ReplaceCode(*info->code()); | 893 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 | 894 |
889 return info->code(); | 895 return info->code(); |
890 } | 896 } |
891 | 897 |
892 | 898 |
893 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( | 899 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( |
894 Handle<JSFunction> function, BailoutId osr_ast_id) { | 900 Handle<JSFunction> function, BailoutId osr_ast_id) { |
895 Handle<SharedFunctionInfo> shared(function->shared()); | 901 Handle<SharedFunctionInfo> shared(function->shared()); |
896 DisallowHeapAllocation no_gc; | 902 DisallowHeapAllocation no_gc; |
897 CodeAndLiterals cached = shared->SearchOptimizedCodeMap( | 903 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()); | 1375 LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal()); |
1370 if (!CompileUnoptimizedCode(&info)) return; | 1376 if (!CompileUnoptimizedCode(&info)) return; |
1371 if (info.has_shared_info()) { | 1377 if (info.has_shared_info()) { |
1372 Handle<ScopeInfo> scope_info = | 1378 Handle<ScopeInfo> scope_info = |
1373 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); | 1379 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); |
1374 info.shared_info()->set_scope_info(*scope_info); | 1380 info.shared_info()->set_scope_info(*scope_info); |
1375 } | 1381 } |
1376 tracker.RecordRootFunctionInfo(info.code()); | 1382 tracker.RecordRootFunctionInfo(info.code()); |
1377 } | 1383 } |
1378 | 1384 |
1385 static Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral( | |
1386 Isolate* isolate, FunctionLiteral* literal, Handle<Script> script) { | |
1387 Handle<Code> code = isolate->builtins()->CompileLazy(); | |
1388 Handle<ScopeInfo> scope_info = handle(ScopeInfo::Empty(isolate)); | |
1389 Handle<SharedFunctionInfo> result = isolate->factory()->NewSharedFunctionInfo( | |
1390 literal->name(), literal->materialized_literal_count(), literal->kind(), | |
1391 code, scope_info); | |
1392 SharedFunctionInfo::InitFromFunctionLiteral(result, literal); | |
1393 SharedFunctionInfo::SetScript(result, script); | |
1394 return result; | |
1395 } | |
1379 | 1396 |
1380 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { | 1397 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { |
1381 Isolate* isolate = info->isolate(); | 1398 Isolate* isolate = info->isolate(); |
1382 TimerEventScope<TimerEventCompileCode> timer(isolate); | 1399 TimerEventScope<TimerEventCompileCode> timer(isolate); |
1383 TRACE_EVENT0("v8", "V8.CompileCode"); | 1400 TRACE_EVENT0("v8", "V8.CompileCode"); |
1384 PostponeInterruptsScope postpone(isolate); | 1401 PostponeInterruptsScope postpone(isolate); |
1385 DCHECK(!isolate->native_context().is_null()); | 1402 DCHECK(!isolate->native_context().is_null()); |
1386 ParseInfo* parse_info = info->parse_info(); | 1403 ParseInfo* parse_info = info->parse_info(); |
1387 Handle<Script> script = parse_info->script(); | 1404 Handle<Script> script = parse_info->script(); |
1388 | 1405 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1438 | 1455 |
1439 // Measure how long it takes to do the compilation; only take the | 1456 // Measure how long it takes to do the compilation; only take the |
1440 // rest of the function into account to avoid overlap with the | 1457 // rest of the function into account to avoid overlap with the |
1441 // parsing statistics. | 1458 // parsing statistics. |
1442 HistogramTimer* rate = info->is_eval() | 1459 HistogramTimer* rate = info->is_eval() |
1443 ? info->isolate()->counters()->compile_eval() | 1460 ? info->isolate()->counters()->compile_eval() |
1444 : info->isolate()->counters()->compile(); | 1461 : info->isolate()->counters()->compile(); |
1445 HistogramTimerScope timer(rate); | 1462 HistogramTimerScope timer(rate); |
1446 TRACE_EVENT0("v8", info->is_eval() ? "V8.CompileEval" : "V8.Compile"); | 1463 TRACE_EVENT0("v8", info->is_eval() ? "V8.CompileEval" : "V8.Compile"); |
1447 | 1464 |
1465 // Allocate a shared function info object. | |
1466 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | |
1467 result = NewSharedFunctionInfoForLiteral(isolate, lit, 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 | |
1448 // Compile the code. | 1474 // Compile the code. |
1449 if (!CompileBaselineCode(info)) { | 1475 if (!CompileBaselineCode(info)) { |
1450 return Handle<SharedFunctionInfo>::null(); | 1476 return Handle<SharedFunctionInfo>::null(); |
1451 } | 1477 } |
1452 | 1478 |
1453 // Allocate function. | 1479 // Install compilation result on the shared function info |
1454 DCHECK(!info->code().is_null()); | 1480 Handle<ScopeInfo> scope_info = |
1455 result = isolate->factory()->NewSharedFunctionInfo( | 1481 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); |
1456 lit->name(), lit->materialized_literal_count(), lit->kind(), | 1482 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 | 1483 |
1474 Handle<String> script_name = | 1484 Handle<String> script_name = |
1475 script->name()->IsString() | 1485 script->name()->IsString() |
1476 ? Handle<String>(String::cast(script->name())) | 1486 ? Handle<String>(String::cast(script->name())) |
1477 : isolate->factory()->empty_string(); | 1487 : isolate->factory()->empty_string(); |
1478 Logger::LogEventsAndTags log_tag = info->is_eval() | 1488 Logger::LogEventsAndTags log_tag = info->is_eval() |
1479 ? Logger::EVAL_TAG | 1489 ? Logger::EVAL_TAG |
1480 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); | 1490 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); |
1481 | 1491 |
1482 PROFILE(isolate, CodeCreateEvent(log_tag, *info->abstract_code(), *result, | 1492 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. | 1747 // compiled, continue to decide whether to eagerly compile. |
1738 // Carry on if we are compiling eager to obtain code for debugging, | 1748 // Carry on if we are compiling eager to obtain code for debugging, |
1739 // unless we already have code with debut break slots. | 1749 // unless we already have code with debut break slots. |
1740 Handle<SharedFunctionInfo> existing; | 1750 Handle<SharedFunctionInfo> existing; |
1741 if (maybe_existing.ToHandle(&existing) && existing->is_compiled()) { | 1751 if (maybe_existing.ToHandle(&existing) && existing->is_compiled()) { |
1742 if (!outer_info->is_debug() || existing->HasDebugCode()) { | 1752 if (!outer_info->is_debug() || existing->HasDebugCode()) { |
1743 return existing; | 1753 return existing; |
1744 } | 1754 } |
1745 } | 1755 } |
1746 | 1756 |
1757 // Allocate a shared function info object. | |
1758 Handle<SharedFunctionInfo> result; | |
1759 if (!maybe_existing.ToHandle(&result)) { | |
1760 result = NewSharedFunctionInfoForLiteral(isolate, literal, script); | |
1761 result->set_is_toplevel(false); | |
1762 } | |
1763 | |
1747 Zone zone; | 1764 Zone zone; |
1748 ParseInfo parse_info(&zone, script); | 1765 ParseInfo parse_info(&zone, script); |
1749 CompilationInfo info(&parse_info); | 1766 CompilationInfo info(&parse_info); |
1750 parse_info.set_literal(literal); | 1767 parse_info.set_literal(literal); |
1751 parse_info.set_scope(literal->scope()); | 1768 parse_info.set_scope(literal->scope()); |
1752 parse_info.set_language_mode(literal->scope()->language_mode()); | 1769 parse_info.set_language_mode(literal->scope()->language_mode()); |
1753 if (outer_info->will_serialize()) info.PrepareForSerializing(); | 1770 if (outer_info->will_serialize()) info.PrepareForSerializing(); |
1754 if (outer_info->is_first_compile()) info.MarkAsFirstCompile(); | 1771 if (outer_info->is_first_compile()) info.MarkAsFirstCompile(); |
1755 if (outer_info->is_debug()) info.MarkAsDebug(); | 1772 if (outer_info->is_debug()) info.MarkAsDebug(); |
1756 | 1773 |
(...skipping 15 matching lines...) Expand all Loading... | |
1772 (!info.is_debug() || allow_lazy_without_ctx); | 1789 (!info.is_debug() || allow_lazy_without_ctx); |
1773 | 1790 |
1774 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); | 1791 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); |
1775 | 1792 |
1776 // Consider compiling eagerly when targeting the code cache. | 1793 // Consider compiling eagerly when targeting the code cache. |
1777 lazy &= !(FLAG_serialize_eager && info.will_serialize()); | 1794 lazy &= !(FLAG_serialize_eager && info.will_serialize()); |
1778 | 1795 |
1779 // Generate code | 1796 // Generate code |
1780 TimerEventScope<TimerEventCompileCode> timer(isolate); | 1797 TimerEventScope<TimerEventCompileCode> timer(isolate); |
1781 TRACE_EVENT0("v8", "V8.CompileCode"); | 1798 TRACE_EVENT0("v8", "V8.CompileCode"); |
1782 Handle<ScopeInfo> scope_info; | |
1783 if (lazy) { | 1799 if (lazy) { |
1784 Handle<Code> code = isolate->builtins()->CompileLazy(); | 1800 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)) { | 1801 } else if (Renumber(info.parse_info()) && GenerateBaselineCode(&info)) { |
1796 // Code generation will ensure that the feedback vector is present and | 1802 // Code generation will ensure that the feedback vector is present and |
1797 // appropriately sized. | 1803 // appropriately sized. |
1798 DCHECK(!info.code().is_null()); | 1804 DCHECK(!info.code().is_null()); |
1799 scope_info = ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); | 1805 Handle<ScopeInfo> scope_info = |
1806 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); | |
1800 if (literal->should_eager_compile() && | 1807 if (literal->should_eager_compile() && |
1801 literal->should_be_used_once_hint()) { | 1808 literal->should_be_used_once_hint()) { |
1802 info.code()->MarkToBeExecutedOnce(isolate); | 1809 info.code()->MarkToBeExecutedOnce(isolate); |
1803 } | 1810 } |
1811 // Assert that we are not overwriting (possibly patched) debug code. | |
1812 DCHECK(!result->HasDebugCode()); | |
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()); | |
Yang
2016/03/18 06:35:25
Can we move this check to InstallBaselineCompilati
Michael Starzinger
2016/03/18 10:05:17
Done.
| |
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 |