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

Side by Side Diff: src/compiler.cc

Issue 1764023003: [compiler] Move JSFunction post-instantiation tasks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 9 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
« no previous file with comments | « src/compiler.h ('k') | src/factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) { 1509 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) {
1510 shared_info->DisableOptimization(kEval); 1510 shared_info->DisableOptimization(kEval);
1511 } 1511 }
1512 1512
1513 // If caller is strict mode, the result must be in strict mode as well. 1513 // If caller is strict mode, the result must be in strict mode as well.
1514 DCHECK(is_sloppy(language_mode) || 1514 DCHECK(is_sloppy(language_mode) ||
1515 is_strict(shared_info->language_mode())); 1515 is_strict(shared_info->language_mode()));
1516 compilation_cache->PutEval(source, outer_info, context, shared_info, 1516 compilation_cache->PutEval(source, outer_info, context, shared_info,
1517 line_offset); 1517 line_offset);
1518 } 1518 }
1519 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) {
1520 shared_info->ResetForNewContext(isolate->heap()->global_ic_age());
1521 } 1519 }
1522 1520
1523 Handle<JSFunction> result = 1521 Handle<JSFunction> result =
1524 isolate->factory()->NewFunctionFromSharedFunctionInfo( 1522 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1525 shared_info, context, NOT_TENURED); 1523 shared_info, context, NOT_TENURED);
1526 1524
1527 // OnAfterCompile has to be called after we create the JSFunction, which we 1525 // OnAfterCompile has to be called after we create the JSFunction, which we
1528 // may require to recompile the eval for debugging, if we find a function 1526 // may require to recompile the eval for debugging, if we find a function
1529 // that contains break points in the eval script. 1527 // that contains break points in the eval script.
1530 isolate->debug()->OnAfterCompile(script); 1528 isolate->debug()->OnAfterCompile(script);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 1899
1902 DCHECK(job->last_status() != OptimizedCompileJob::SUCCEEDED); 1900 DCHECK(job->last_status() != OptimizedCompileJob::SUCCEEDED);
1903 if (FLAG_trace_opt) { 1901 if (FLAG_trace_opt) {
1904 PrintF("[aborted optimizing "); 1902 PrintF("[aborted optimizing ");
1905 info->closure()->ShortPrint(); 1903 info->closure()->ShortPrint();
1906 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); 1904 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason()));
1907 } 1905 }
1908 return MaybeHandle<Code>(); 1906 return MaybeHandle<Code>();
1909 } 1907 }
1910 1908
1909 void Compiler::PostInstantiation(Handle<JSFunction> function,
1910 PretenureFlag pretenure) {
1911 Handle<SharedFunctionInfo> shared(function->shared());
1912
1913 if (FLAG_always_opt && shared->allows_lazy_compilation()) {
1914 function->MarkForOptimization();
1915 }
1916
1917 CodeAndLiterals cached = shared->SearchOptimizedCodeMap(
1918 function->context()->native_context(), BailoutId::None());
1919 if (cached.code != nullptr) {
1920 // Caching of optimized code enabled and optimized code found.
1921 DCHECK(!cached.code->marked_for_deoptimization());
1922 DCHECK(function->shared()->is_compiled());
1923 function->ReplaceCode(cached.code);
1924 }
1925
1926 if (cached.literals != nullptr) {
1927 function->set_literals(cached.literals);
1928 } else {
1929 Isolate* isolate = function->GetIsolate();
1930 int number_of_literals = shared->num_literals();
1931 Handle<LiteralsArray> literals =
1932 LiteralsArray::New(isolate, handle(shared->feedback_vector()),
1933 number_of_literals, pretenure);
1934 function->set_literals(*literals);
1935
1936 // Cache context-specific literals.
1937 MaybeHandle<Code> code;
1938 if (cached.code != nullptr) code = handle(cached.code);
1939 Handle<Context> native_context(function->context()->native_context());
1940 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
1941 literals, BailoutId::None());
1942 }
1943 }
1911 1944
1912 #if DEBUG 1945 #if DEBUG
1913 void CompilationInfo::PrintAstForTesting() { 1946 void CompilationInfo::PrintAstForTesting() {
1914 PrintF("--- Source from AST ---\n%s\n", 1947 PrintF("--- Source from AST ---\n%s\n",
1915 PrettyPrinter(isolate()).PrintProgram(literal())); 1948 PrettyPrinter(isolate()).PrintProgram(literal()));
1916 } 1949 }
1917 #endif 1950 #endif
1918 1951
1919 } // namespace internal 1952 } // namespace internal
1920 } // namespace v8 1953 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698