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 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 if (!isolate->has_pending_exception()) isolate->StackOverflow(); | 389 if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
390 return false; | 390 return false; |
391 } | 391 } |
392 return true; | 392 return true; |
393 } | 393 } |
394 | 394 |
395 void InstallSharedScopeInfo(CompilationInfo* info, | 395 void InstallSharedScopeInfo(CompilationInfo* info, |
396 Handle<SharedFunctionInfo> shared) { | 396 Handle<SharedFunctionInfo> shared) { |
397 Handle<ScopeInfo> scope_info = info->scope()->scope_info(); | 397 Handle<ScopeInfo> scope_info = info->scope()->scope_info(); |
398 shared->set_scope_info(*scope_info); | 398 shared->set_scope_info(*scope_info); |
| 399 Scope* outer_scope = info->scope()->GetOuterScopeWithContext(); |
| 400 if (outer_scope) { |
| 401 shared->set_outer_scope_info(*outer_scope->scope_info()); |
| 402 } |
399 } | 403 } |
400 | 404 |
401 void InstallSharedCompilationResult(CompilationInfo* info, | 405 void InstallSharedCompilationResult(CompilationInfo* info, |
402 Handle<SharedFunctionInfo> shared) { | 406 Handle<SharedFunctionInfo> shared) { |
403 // TODO(mstarzinger): Compiling for debug code might be used to reveal inner | 407 // TODO(mstarzinger): Compiling for debug code might be used to reveal inner |
404 // functions via {FindSharedFunctionInfoInScript}, in which case we end up | 408 // functions via {FindSharedFunctionInfoInScript}, in which case we end up |
405 // regenerating existing bytecode. Fix this! | 409 // regenerating existing bytecode. Fix this! |
406 if (info->is_debug() && info->has_bytecode_array()) { | 410 if (info->is_debug() && info->has_bytecode_array()) { |
407 shared->ClearBytecodeArray(); | 411 shared->ClearBytecodeArray(); |
408 } | 412 } |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 lazy &= | 1796 lazy &= |
1793 !(FLAG_ignition && FLAG_ignition_eager && !isolate->serializer_enabled()); | 1797 !(FLAG_ignition && FLAG_ignition_eager && !isolate->serializer_enabled()); |
1794 | 1798 |
1795 // Generate code | 1799 // Generate code |
1796 TimerEventScope<TimerEventCompileCode> timer(isolate); | 1800 TimerEventScope<TimerEventCompileCode> timer(isolate); |
1797 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode); | 1801 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode); |
1798 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); | 1802 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); |
1799 | 1803 |
1800 if (lazy) { | 1804 if (lazy) { |
1801 info.SetCode(isolate->builtins()->CompileLazy()); | 1805 info.SetCode(isolate->builtins()->CompileLazy()); |
| 1806 Scope* outer_scope = literal->scope()->GetOuterScopeWithContext(); |
| 1807 if (outer_scope) { |
| 1808 result->set_outer_scope_info(*outer_scope->scope_info()); |
| 1809 } |
1802 } else if (Renumber(info.parse_info()) && GenerateUnoptimizedCode(&info)) { | 1810 } else if (Renumber(info.parse_info()) && GenerateUnoptimizedCode(&info)) { |
1803 // Code generation will ensure that the feedback vector is present and | 1811 // Code generation will ensure that the feedback vector is present and |
1804 // appropriately sized. | 1812 // appropriately sized. |
1805 DCHECK(!info.code().is_null()); | 1813 DCHECK(!info.code().is_null()); |
1806 if (literal->should_eager_compile() && | 1814 if (literal->should_eager_compile() && |
1807 literal->should_be_used_once_hint()) { | 1815 literal->should_be_used_once_hint()) { |
1808 info.code()->MarkToBeExecutedOnce(isolate); | 1816 info.code()->MarkToBeExecutedOnce(isolate); |
1809 } | 1817 } |
1810 // Update the shared function info with the scope info. | 1818 // Update the shared function info with the scope info. |
1811 InstallSharedScopeInfo(&info, result); | 1819 InstallSharedScopeInfo(&info, result); |
(...skipping 23 matching lines...) Expand all Loading... |
1835 | 1843 |
1836 // Instantiate the function and create a shared function info from it. | 1844 // Instantiate the function and create a shared function info from it. |
1837 Handle<JSFunction> fun = Handle<JSFunction>::cast(Utils::OpenHandle( | 1845 Handle<JSFunction> fun = Handle<JSFunction>::cast(Utils::OpenHandle( |
1838 *fun_template->GetFunction(v8_isolate->GetCurrentContext()) | 1846 *fun_template->GetFunction(v8_isolate->GetCurrentContext()) |
1839 .ToLocalChecked())); | 1847 .ToLocalChecked())); |
1840 Handle<Code> code = Handle<Code>(fun->shared()->code()); | 1848 Handle<Code> code = Handle<Code>(fun->shared()->code()); |
1841 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); | 1849 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); |
1842 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( | 1850 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( |
1843 name, fun->shared()->num_literals(), FunctionKind::kNormalFunction, code, | 1851 name, fun->shared()->num_literals(), FunctionKind::kNormalFunction, code, |
1844 Handle<ScopeInfo>(fun->shared()->scope_info())); | 1852 Handle<ScopeInfo>(fun->shared()->scope_info())); |
| 1853 shared->set_outer_scope_info(fun->shared()->outer_scope_info()); |
1845 shared->SetConstructStub(*construct_stub); | 1854 shared->SetConstructStub(*construct_stub); |
1846 shared->set_feedback_metadata(fun->shared()->feedback_metadata()); | 1855 shared->set_feedback_metadata(fun->shared()->feedback_metadata()); |
1847 | 1856 |
1848 // Copy the function data to the shared function info. | 1857 // Copy the function data to the shared function info. |
1849 shared->set_function_data(fun->shared()->function_data()); | 1858 shared->set_function_data(fun->shared()->function_data()); |
1850 int parameters = fun->shared()->internal_formal_parameter_count(); | 1859 int parameters = fun->shared()->internal_formal_parameter_count(); |
1851 shared->set_internal_formal_parameter_count(parameters); | 1860 shared->set_internal_formal_parameter_count(parameters); |
1852 | 1861 |
1853 return shared; | 1862 return shared; |
1854 } | 1863 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 DCHECK(shared->is_compiled()); | 1915 DCHECK(shared->is_compiled()); |
1907 function->set_literals(cached.literals); | 1916 function->set_literals(cached.literals); |
1908 } else if (shared->is_compiled()) { | 1917 } else if (shared->is_compiled()) { |
1909 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1918 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1910 JSFunction::EnsureLiterals(function); | 1919 JSFunction::EnsureLiterals(function); |
1911 } | 1920 } |
1912 } | 1921 } |
1913 | 1922 |
1914 } // namespace internal | 1923 } // namespace internal |
1915 } // namespace v8 | 1924 } // namespace v8 |
OLD | NEW |