| 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 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 } | 1864 } |
| 1865 | 1865 |
| 1866 MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function, | 1866 MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function, |
| 1867 BailoutId osr_ast_id, | 1867 BailoutId osr_ast_id, |
| 1868 JavaScriptFrame* osr_frame) { | 1868 JavaScriptFrame* osr_frame) { |
| 1869 DCHECK(!osr_ast_id.IsNone()); | 1869 DCHECK(!osr_ast_id.IsNone()); |
| 1870 DCHECK_NOT_NULL(osr_frame); | 1870 DCHECK_NOT_NULL(osr_frame); |
| 1871 return GetOptimizedCode(function, NOT_CONCURRENT, osr_ast_id, osr_frame); | 1871 return GetOptimizedCode(function, NOT_CONCURRENT, osr_ast_id, osr_frame); |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 MaybeHandle<Code> Compiler::GetConcurrentlyOptimizedCode( | 1874 void Compiler::FinalizeOptimizedCompileJob(OptimizedCompileJob* job) { |
| 1875 OptimizedCompileJob* job) { | |
| 1876 // Take ownership of compilation info. Deleting compilation info | 1875 // Take ownership of compilation info. Deleting compilation info |
| 1877 // also tears down the zone and the recompile job. | 1876 // also tears down the zone and the recompile job. |
| 1878 base::SmartPointer<CompilationInfo> info(job->info()); | 1877 base::SmartPointer<CompilationInfo> info(job->info()); |
| 1879 Isolate* isolate = info->isolate(); | 1878 Isolate* isolate = info->isolate(); |
| 1880 | 1879 |
| 1881 VMState<COMPILER> state(isolate); | 1880 VMState<COMPILER> state(isolate); |
| 1882 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); | 1881 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); |
| 1883 TRACE_EVENT0("v8", "V8.RecompileSynchronous"); | 1882 TRACE_EVENT0("v8", "V8.RecompileSynchronous"); |
| 1884 | 1883 |
| 1885 Handle<SharedFunctionInfo> shared = info->shared_info(); | 1884 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1901 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info.get(), shared); | 1900 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info.get(), shared); |
| 1902 if (shared->SearchOptimizedCodeMap(info->context()->native_context(), | 1901 if (shared->SearchOptimizedCodeMap(info->context()->native_context(), |
| 1903 info->osr_ast_id()).code == nullptr) { | 1902 info->osr_ast_id()).code == nullptr) { |
| 1904 InsertCodeIntoOptimizedCodeMap(info.get()); | 1903 InsertCodeIntoOptimizedCodeMap(info.get()); |
| 1905 } | 1904 } |
| 1906 if (FLAG_trace_opt) { | 1905 if (FLAG_trace_opt) { |
| 1907 PrintF("[completed optimizing "); | 1906 PrintF("[completed optimizing "); |
| 1908 info->closure()->ShortPrint(); | 1907 info->closure()->ShortPrint(); |
| 1909 PrintF("]\n"); | 1908 PrintF("]\n"); |
| 1910 } | 1909 } |
| 1911 return Handle<Code>(*info->code()); | 1910 info->closure()->ReplaceCode(*info->code()); |
| 1911 return; |
| 1912 } | 1912 } |
| 1913 } | 1913 } |
| 1914 | 1914 |
| 1915 DCHECK(job->last_status() != OptimizedCompileJob::SUCCEEDED); | 1915 DCHECK(job->last_status() != OptimizedCompileJob::SUCCEEDED); |
| 1916 if (FLAG_trace_opt) { | 1916 if (FLAG_trace_opt) { |
| 1917 PrintF("[aborted optimizing "); | 1917 PrintF("[aborted optimizing "); |
| 1918 info->closure()->ShortPrint(); | 1918 info->closure()->ShortPrint(); |
| 1919 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); | 1919 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); |
| 1920 } | 1920 } |
| 1921 return MaybeHandle<Code>(); | 1921 info->closure()->ReplaceCode(shared->code()); |
| 1922 } | 1922 } |
| 1923 | 1923 |
| 1924 void Compiler::PostInstantiation(Handle<JSFunction> function, | 1924 void Compiler::PostInstantiation(Handle<JSFunction> function, |
| 1925 PretenureFlag pretenure) { | 1925 PretenureFlag pretenure) { |
| 1926 Handle<SharedFunctionInfo> shared(function->shared()); | 1926 Handle<SharedFunctionInfo> shared(function->shared()); |
| 1927 | 1927 |
| 1928 if (FLAG_always_opt && shared->allows_lazy_compilation()) { | 1928 if (FLAG_always_opt && shared->allows_lazy_compilation()) { |
| 1929 function->MarkForOptimization(); | 1929 function->MarkForOptimization(); |
| 1930 } | 1930 } |
| 1931 | 1931 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1959 | 1959 |
| 1960 #if DEBUG | 1960 #if DEBUG |
| 1961 void CompilationInfo::PrintAstForTesting() { | 1961 void CompilationInfo::PrintAstForTesting() { |
| 1962 PrintF("--- Source from AST ---\n%s\n", | 1962 PrintF("--- Source from AST ---\n%s\n", |
| 1963 PrettyPrinter(isolate()).PrintProgram(literal())); | 1963 PrettyPrinter(isolate()).PrintProgram(literal())); |
| 1964 } | 1964 } |
| 1965 #endif | 1965 #endif |
| 1966 | 1966 |
| 1967 } // namespace internal | 1967 } // namespace internal |
| 1968 } // namespace v8 | 1968 } // namespace v8 |
| OLD | NEW |