Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: src/compiler.cc

Issue 2399833002: Teach Scopes whether they will end up being lazily compiled or not (Closed)
Patch Set: updates Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 InstallSharedScopeInfo(info, shared); 1424 InstallSharedScopeInfo(info, shared);
1425 } 1425 }
1426 1426
1427 // Install compilation result on the shared function info 1427 // Install compilation result on the shared function info
1428 shared->EnableDeoptimizationSupport(*unoptimized.code()); 1428 shared->EnableDeoptimizationSupport(*unoptimized.code());
1429 1429
1430 // The existing unoptimized code was replaced with the new one. 1430 // The existing unoptimized code was replaced with the new one.
1431 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, 1431 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG,
1432 &unoptimized); 1432 &unoptimized);
1433 } 1433 }
1434 info->parse_info()->set_will_serialize(false);
marja 2016/10/07 08:25:59 Comment suggestion: We reuse the same ParseInfo i
jochen (gone - plz use gerrit) 2016/10/07 08:34:37 I moved the code it but further up and added a com
1434 return true; 1435 return true;
1435 } 1436 }
1436 1437
1437 // static 1438 // static
1438 Compiler::CompilationTier Compiler::NextCompilationTier(JSFunction* function) { 1439 Compiler::CompilationTier Compiler::NextCompilationTier(JSFunction* function) {
1439 Handle<SharedFunctionInfo> shared(function->shared(), function->GetIsolate()); 1440 Handle<SharedFunctionInfo> shared(function->shared(), function->GetIsolate());
1440 if (shared->code()->is_interpreter_trampoline_builtin()) { 1441 if (shared->code()->is_interpreter_trampoline_builtin()) {
1441 if (FLAG_turbo_from_bytecode && UseTurboFan(shared)) { 1442 if (FLAG_turbo_from_bytecode && UseTurboFan(shared)) {
1442 return OPTIMIZED; 1443 return OPTIMIZED;
1443 } else { 1444 } else {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 1769
1769 Zone zone(isolate->allocator()); 1770 Zone zone(isolate->allocator());
1770 ParseInfo parse_info(&zone, script); 1771 ParseInfo parse_info(&zone, script);
1771 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); 1772 CompilationInfo info(&parse_info, Handle<JSFunction>::null());
1772 parse_info.set_literal(literal); 1773 parse_info.set_literal(literal);
1773 parse_info.set_shared_info(result); 1774 parse_info.set_shared_info(result);
1774 parse_info.set_language_mode(literal->scope()->language_mode()); 1775 parse_info.set_language_mode(literal->scope()->language_mode());
1775 if (outer_info->will_serialize()) info.PrepareForSerializing(); 1776 if (outer_info->will_serialize()) info.PrepareForSerializing();
1776 if (outer_info->is_debug()) info.MarkAsDebug(); 1777 if (outer_info->is_debug()) info.MarkAsDebug();
1777 1778
1778 // Determine if the function can be lazily compiled. This is necessary to
1779 // allow some of our builtin JS files to be lazily compiled. These
1780 // builtins cannot be handled lazily by the parser, since we have to know
1781 // if a function uses the special natives syntax, which is something the
1782 // parser records.
1783 // If the debugger requests compilation for break points, we cannot be
1784 // aggressive about lazy compilation, because it might trigger compilation
1785 // of functions without an outer context when setting a breakpoint through
1786 // Debug::FindSharedFunctionInfoInScript.
1787 bool allow_lazy = literal->AllowsLazyCompilation() && !info.is_debug();
1788 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile();
1789
1790 // Consider compiling eagerly when targeting the code cache.
1791 lazy &= !(FLAG_serialize_eager && info.will_serialize());
1792
1793 // Consider compiling eagerly when compiling bytecode for Ignition.
1794 lazy &=
1795 !(FLAG_ignition && FLAG_ignition_eager && !isolate->serializer_enabled());
1796
1797 // Generate code 1779 // Generate code
1798 TimerEventScope<TimerEventCompileCode> timer(isolate); 1780 TimerEventScope<TimerEventCompileCode> timer(isolate);
1799 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode); 1781 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode);
1800 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); 1782 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode");
1801 1783
1802 if (lazy) { 1784 if (!literal->ShouldEagerCompile()) {
1803 info.SetCode(isolate->builtins()->CompileLazy()); 1785 info.SetCode(isolate->builtins()->CompileLazy());
1804 Scope* outer_scope = literal->scope()->GetOuterScopeWithContext(); 1786 Scope* outer_scope = literal->scope()->GetOuterScopeWithContext();
1805 if (outer_scope) { 1787 if (outer_scope) {
1806 result->set_outer_scope_info(*outer_scope->scope_info()); 1788 result->set_outer_scope_info(*outer_scope->scope_info());
1807 } 1789 }
1808 } else if (Renumber(info.parse_info()) && GenerateUnoptimizedCode(&info)) { 1790 } else if (Renumber(info.parse_info()) && GenerateUnoptimizedCode(&info)) {
1809 // Code generation will ensure that the feedback vector is present and 1791 // Code generation will ensure that the feedback vector is present and
1810 // appropriately sized. 1792 // appropriately sized.
1811 DCHECK(!info.code().is_null()); 1793 DCHECK(!info.code().is_null());
1812 if (literal->should_eager_compile() && 1794 if (literal->ShouldEagerCompile() && literal->should_be_used_once_hint()) {
marja 2016/10/07 08:25:59 Wait, isn't this always true now, since we are in
jochen (gone - plz use gerrit) 2016/10/07 08:34:37 I removed the ShouldEagerCompilePart()
1813 literal->should_be_used_once_hint()) {
1814 info.code()->MarkToBeExecutedOnce(isolate); 1795 info.code()->MarkToBeExecutedOnce(isolate);
1815 } 1796 }
1816 // Update the shared function info with the scope info. 1797 // Update the shared function info with the scope info.
1817 InstallSharedScopeInfo(&info, result); 1798 InstallSharedScopeInfo(&info, result);
1818 // Install compilation result on the shared function info. 1799 // Install compilation result on the shared function info.
1819 InstallSharedCompilationResult(&info, result); 1800 InstallSharedCompilationResult(&info, result);
1820 } else { 1801 } else {
1821 return Handle<SharedFunctionInfo>::null(); 1802 return Handle<SharedFunctionInfo>::null();
1822 } 1803 }
1823 1804
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 DCHECK(shared->is_compiled()); 1894 DCHECK(shared->is_compiled());
1914 function->set_literals(cached.literals); 1895 function->set_literals(cached.literals);
1915 } else if (shared->is_compiled()) { 1896 } else if (shared->is_compiled()) {
1916 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1897 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1917 JSFunction::EnsureLiterals(function); 1898 JSFunction::EnsureLiterals(function);
1918 } 1899 }
1919 } 1900 }
1920 1901
1921 } // namespace internal 1902 } // namespace internal
1922 } // namespace v8 1903 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698