| 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 849 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   860     Deoptimizer::VisitAllOptimizedFunctions(isolate, activations_finder); |   860     Deoptimizer::VisitAllOptimizedFunctions(isolate, activations_finder); | 
|   861   } |   861   } | 
|   862   return activations_finder->has_activations(); |   862   return activations_finder->has_activations(); | 
|   863 } |   863 } | 
|   864  |   864  | 
|   865 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { |   865 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { | 
|   866   Isolate* isolate = function->GetIsolate(); |   866   Isolate* isolate = function->GetIsolate(); | 
|   867   VMState<COMPILER> state(isolate); |   867   VMState<COMPILER> state(isolate); | 
|   868   PostponeInterruptsScope postpone(isolate); |   868   PostponeInterruptsScope postpone(isolate); | 
|   869   Zone zone(isolate->allocator()); |   869   Zone zone(isolate->allocator()); | 
|   870   ParseInfo parse_info(&zone, function); |   870   ParseInfo parse_info(&zone, handle(function->shared())); | 
|   871   CompilationInfo info(&parse_info, function); |   871   CompilationInfo info(&parse_info, function); | 
|   872  |   872  | 
|   873   // Reset profiler ticks, function is no longer considered hot. |   873   // Reset profiler ticks, function is no longer considered hot. | 
|   874   if (function->shared()->HasBytecodeArray()) { |   874   if (function->shared()->HasBytecodeArray()) { | 
|   875     function->shared()->set_profiler_ticks(0); |   875     function->shared()->set_profiler_ticks(0); | 
|   876   } |   876   } | 
|   877  |   877  | 
|   878   // Nothing left to do if the function already has baseline code. |   878   // Nothing left to do if the function already has baseline code. | 
|   879   if (function->shared()->code()->kind() == Code::FUNCTION) { |   879   if (function->shared()->code()->kind() == Code::FUNCTION) { | 
|   880     return Handle<Code>(function->shared()->code()); |   880     return Handle<Code>(function->shared()->code()); | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   981     return Handle<Code>(function->shared()->code()); |   981     return Handle<Code>(function->shared()->code()); | 
|   982   } |   982   } | 
|   983  |   983  | 
|   984   if (function->shared()->HasBytecodeArray()) { |   984   if (function->shared()->HasBytecodeArray()) { | 
|   985     Handle<Code> entry = isolate->builtins()->InterpreterEntryTrampoline(); |   985     Handle<Code> entry = isolate->builtins()->InterpreterEntryTrampoline(); | 
|   986     function->shared()->ReplaceCode(*entry); |   986     function->shared()->ReplaceCode(*entry); | 
|   987     return entry; |   987     return entry; | 
|   988   } |   988   } | 
|   989  |   989  | 
|   990   Zone zone(isolate->allocator()); |   990   Zone zone(isolate->allocator()); | 
|   991   ParseInfo parse_info(&zone, function); |   991   ParseInfo parse_info(&zone, handle(function->shared())); | 
|   992   CompilationInfo info(&parse_info, function); |   992   CompilationInfo info(&parse_info, function); | 
|   993   Handle<Code> result; |   993   Handle<Code> result; | 
|   994   ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); |   994   ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); | 
|   995  |   995  | 
|   996   if (FLAG_always_opt) { |   996   if (FLAG_always_opt) { | 
|   997     Handle<Code> opt_code; |   997     Handle<Code> opt_code; | 
|   998     if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) |   998     if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) | 
|   999             .ToHandle(&opt_code)) { |   999             .ToHandle(&opt_code)) { | 
|  1000       result = opt_code; |  1000       result = opt_code; | 
|  1001     } |  1001     } | 
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1167   if (!GetOptimizedCode(function, mode).ToHandle(&code)) { |  1167   if (!GetOptimizedCode(function, mode).ToHandle(&code)) { | 
|  1168     // Optimization failed, get unoptimized code. |  1168     // Optimization failed, get unoptimized code. | 
|  1169     DCHECK(!isolate->has_pending_exception()); |  1169     DCHECK(!isolate->has_pending_exception()); | 
|  1170     if (function->shared()->is_compiled()) { |  1170     if (function->shared()->is_compiled()) { | 
|  1171       code = handle(function->shared()->code(), isolate); |  1171       code = handle(function->shared()->code(), isolate); | 
|  1172     } else if (function->shared()->HasBytecodeArray()) { |  1172     } else if (function->shared()->HasBytecodeArray()) { | 
|  1173       code = isolate->builtins()->InterpreterEntryTrampoline(); |  1173       code = isolate->builtins()->InterpreterEntryTrampoline(); | 
|  1174       function->shared()->ReplaceCode(*code); |  1174       function->shared()->ReplaceCode(*code); | 
|  1175     } else { |  1175     } else { | 
|  1176       Zone zone(isolate->allocator()); |  1176       Zone zone(isolate->allocator()); | 
|  1177       ParseInfo parse_info(&zone, function); |  1177       ParseInfo parse_info(&zone, handle(function->shared())); | 
|  1178       CompilationInfo info(&parse_info, function); |  1178       CompilationInfo info(&parse_info, function); | 
|  1179       if (!GetUnoptimizedCode(&info).ToHandle(&code)) { |  1179       if (!GetUnoptimizedCode(&info).ToHandle(&code)) { | 
|  1180         return false; |  1180         return false; | 
|  1181       } |  1181       } | 
|  1182     } |  1182     } | 
|  1183   } |  1183   } | 
|  1184  |  1184  | 
|  1185   // Install code on closure. |  1185   // Install code on closure. | 
|  1186   function->ReplaceCode(*code); |  1186   function->ReplaceCode(*code); | 
|  1187   JSFunction::EnsureLiterals(function); |  1187   JSFunction::EnsureLiterals(function); | 
|  1188  |  1188  | 
|  1189   // Check postconditions on success. |  1189   // Check postconditions on success. | 
|  1190   DCHECK(!isolate->has_pending_exception()); |  1190   DCHECK(!isolate->has_pending_exception()); | 
|  1191   DCHECK(function->shared()->is_compiled()); |  1191   DCHECK(function->shared()->is_compiled()); | 
|  1192   DCHECK(function->is_compiled()); |  1192   DCHECK(function->is_compiled()); | 
|  1193   return true; |  1193   return true; | 
|  1194 } |  1194 } | 
|  1195  |  1195  | 
|  1196 bool Compiler::CompileDebugCode(Handle<JSFunction> function) { |  1196 bool Compiler::CompileDebugCode(Handle<JSFunction> function) { | 
|  1197   Isolate* isolate = function->GetIsolate(); |  1197   Isolate* isolate = function->GetIsolate(); | 
|  1198   DCHECK(AllowCompilation::IsAllowed(isolate)); |  1198   DCHECK(AllowCompilation::IsAllowed(isolate)); | 
|  1199  |  1199  | 
|  1200   // Start a compilation. |  1200   // Start a compilation. | 
|  1201   Zone zone(isolate->allocator()); |  1201   Zone zone(isolate->allocator()); | 
|  1202   ParseInfo parse_info(&zone, function); |  1202   ParseInfo parse_info(&zone, handle(function->shared())); | 
|  1203   CompilationInfo info(&parse_info, Handle<JSFunction>::null()); |  1203   CompilationInfo info(&parse_info, Handle<JSFunction>::null()); | 
|  1204   info.MarkAsDebug(); |  1204   info.MarkAsDebug(); | 
|  1205   if (GetUnoptimizedCode(&info).is_null()) { |  1205   if (GetUnoptimizedCode(&info).is_null()) { | 
|  1206     isolate->clear_pending_exception(); |  1206     isolate->clear_pending_exception(); | 
|  1207     return false; |  1207     return false; | 
|  1208   } |  1208   } | 
|  1209  |  1209  | 
|  1210   // Check postconditions on success. |  1210   // Check postconditions on success. | 
|  1211   DCHECK(!isolate->has_pending_exception()); |  1211   DCHECK(!isolate->has_pending_exception()); | 
|  1212   DCHECK(function->shared()->is_compiled()); |  1212   DCHECK(function->shared()->is_compiled()); | 
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1812     DCHECK(shared->is_compiled()); |  1812     DCHECK(shared->is_compiled()); | 
|  1813     function->set_literals(cached.literals); |  1813     function->set_literals(cached.literals); | 
|  1814   } else if (shared->is_compiled()) { |  1814   } else if (shared->is_compiled()) { | 
|  1815     // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |  1815     // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 
|  1816     JSFunction::EnsureLiterals(function); |  1816     JSFunction::EnsureLiterals(function); | 
|  1817   } |  1817   } | 
|  1818 } |  1818 } | 
|  1819  |  1819  | 
|  1820 }  // namespace internal |  1820 }  // namespace internal | 
|  1821 }  // namespace v8 |  1821 }  // namespace v8 | 
| OLD | NEW |