| 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-numbering.h" | 9 #include "src/ast-numbering.h" | 
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 107   // Compiling for the snapshot typically results in different code than | 107   // Compiling for the snapshot typically results in different code than | 
| 108   // compiling later on. This means that code recompiled with deoptimization | 108   // compiling later on. This means that code recompiled with deoptimization | 
| 109   // support won't be "equivalent" (as defined by SharedFunctionInfo:: | 109   // support won't be "equivalent" (as defined by SharedFunctionInfo:: | 
| 110   // EnableDeoptimizationSupport), so it will replace the old code and all | 110   // EnableDeoptimizationSupport), so it will replace the old code and all | 
| 111   // its type feedback. To avoid this, always compile functions in the snapshot | 111   // its type feedback. To avoid this, always compile functions in the snapshot | 
| 112   // with deoptimization support. | 112   // with deoptimization support. | 
| 113   if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); | 113   if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); | 
| 114 | 114 | 
| 115   if (isolate_->debug()->is_active()) MarkAsDebug(); | 115   if (isolate_->debug()->is_active()) MarkAsDebug(); | 
| 116   if (FLAG_context_specialization) MarkAsContextSpecializing(); | 116   if (FLAG_context_specialization) MarkAsContextSpecializing(); | 
| 117   if (FLAG_turbo_deoptimization) MarkAsDeoptimizationEnabled(); |  | 
| 118   if (FLAG_turbo_inlining) MarkAsInliningEnabled(); | 117   if (FLAG_turbo_inlining) MarkAsInliningEnabled(); | 
| 119   if (FLAG_turbo_source_positions) MarkAsSourcePositionsEnabled(); | 118   if (FLAG_turbo_source_positions) MarkAsSourcePositionsEnabled(); | 
| 120   if (FLAG_turbo_splitting) MarkAsSplittingEnabled(); | 119   if (FLAG_turbo_splitting) MarkAsSplittingEnabled(); | 
| 121   if (FLAG_turbo_types) MarkAsTypingEnabled(); | 120   if (FLAG_turbo_types) MarkAsTypingEnabled(); | 
| 122 | 121 | 
| 123   if (has_shared_info() && shared_info()->is_compiled()) { | 122   if (has_shared_info() && shared_info()->is_compiled()) { | 
| 124     // We should initialize the CompilationInfo feedback vector from the | 123     // We should initialize the CompilationInfo feedback vector from the | 
| 125     // passed in shared info, rather than creating a new one. | 124     // passed in shared info, rather than creating a new one. | 
| 126     feedback_vector_ = Handle<TypeFeedbackVector>( | 125     feedback_vector_ = Handle<TypeFeedbackVector>( | 
| 127         shared_info()->feedback_vector(), parse_info->isolate()); | 126         shared_info()->feedback_vector(), parse_info->isolate()); | 
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 386       if (info()->is_osr()) os << " OSR"; | 385       if (info()->is_osr()) os << " OSR"; | 
| 387       os << "]" << std::endl; | 386       os << "]" << std::endl; | 
| 388     } | 387     } | 
| 389 | 388 | 
| 390     if (info()->shared_info()->asm_function()) { | 389     if (info()->shared_info()->asm_function()) { | 
| 391       info()->MarkAsContextSpecializing(); | 390       info()->MarkAsContextSpecializing(); | 
| 392     } else if (FLAG_turbo_type_feedback) { | 391     } else if (FLAG_turbo_type_feedback) { | 
| 393       info()->MarkAsTypeFeedbackEnabled(); | 392       info()->MarkAsTypeFeedbackEnabled(); | 
| 394       info()->EnsureFeedbackVector(); | 393       info()->EnsureFeedbackVector(); | 
| 395     } | 394     } | 
|  | 395     if (!info()->shared_info()->asm_function() || | 
|  | 396         FLAG_turbo_asm_deoptimization) { | 
|  | 397       info()->MarkAsDeoptimizationEnabled(); | 
|  | 398     } | 
| 396 | 399 | 
| 397     Timer t(this, &time_taken_to_create_graph_); | 400     Timer t(this, &time_taken_to_create_graph_); | 
| 398     compiler::Pipeline pipeline(info()); | 401     compiler::Pipeline pipeline(info()); | 
| 399     pipeline.GenerateCode(); | 402     pipeline.GenerateCode(); | 
| 400     if (!info()->code().is_null()) { | 403     if (!info()->code().is_null()) { | 
| 401       return SetLastStatus(SUCCEEDED); | 404       return SetLastStatus(SUCCEEDED); | 
| 402     } | 405     } | 
| 403   } | 406   } | 
| 404 | 407 | 
| 405   if (!isolate()->use_crankshaft()) { | 408   if (!isolate()->use_crankshaft()) { | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 495 | 498 | 
| 496   return SetLastStatus(BAILED_OUT); | 499   return SetLastStatus(BAILED_OUT); | 
| 497 } | 500 } | 
| 498 | 501 | 
| 499 | 502 | 
| 500 OptimizedCompileJob::Status OptimizedCompileJob::GenerateCode() { | 503 OptimizedCompileJob::Status OptimizedCompileJob::GenerateCode() { | 
| 501   DCHECK(last_status() == SUCCEEDED); | 504   DCHECK(last_status() == SUCCEEDED); | 
| 502   // TODO(turbofan): Currently everything is done in the first phase. | 505   // TODO(turbofan): Currently everything is done in the first phase. | 
| 503   if (!info()->code().is_null()) { | 506   if (!info()->code().is_null()) { | 
| 504     info()->dependencies()->Commit(info()->code()); | 507     info()->dependencies()->Commit(info()->code()); | 
| 505     if (FLAG_turbo_deoptimization) { | 508     if (info()->is_deoptimization_enabled()) { | 
| 506       info()->parse_info()->context()->native_context()->AddOptimizedCode( | 509       info()->parse_info()->context()->native_context()->AddOptimizedCode( | 
| 507           *info()->code()); | 510           *info()->code()); | 
| 508     } | 511     } | 
| 509     RecordOptimizationStats(); | 512     RecordOptimizationStats(); | 
| 510     return last_status(); | 513     return last_status(); | 
| 511   } | 514   } | 
| 512 | 515 | 
| 513   DCHECK(!info()->dependencies()->HasAborted()); | 516   DCHECK(!info()->dependencies()->HasAborted()); | 
| 514   DisallowCodeDependencyChange no_dependency_change; | 517   DisallowCodeDependencyChange no_dependency_change; | 
| 515   DisallowJavascriptExecution no_js(isolate()); | 518   DisallowJavascriptExecution no_js(isolate()); | 
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 841 | 844 | 
| 842 | 845 | 
| 843 MaybeHandle<Code> Compiler::GetLazyCode(Handle<JSFunction> function) { | 846 MaybeHandle<Code> Compiler::GetLazyCode(Handle<JSFunction> function) { | 
| 844   Isolate* isolate = function->GetIsolate(); | 847   Isolate* isolate = function->GetIsolate(); | 
| 845   DCHECK(!isolate->has_pending_exception()); | 848   DCHECK(!isolate->has_pending_exception()); | 
| 846   DCHECK(!function->is_compiled()); | 849   DCHECK(!function->is_compiled()); | 
| 847   AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 850   AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 
| 848   // If the debugger is active, do not compile with turbofan unless we can | 851   // If the debugger is active, do not compile with turbofan unless we can | 
| 849   // deopt from turbofan code. | 852   // deopt from turbofan code. | 
| 850   if (FLAG_turbo_asm && function->shared()->asm_function() && | 853   if (FLAG_turbo_asm && function->shared()->asm_function() && | 
| 851       (FLAG_turbo_deoptimization || !isolate->debug()->is_active()) && | 854       (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()) && | 
| 852       !FLAG_turbo_osr) { | 855       !FLAG_turbo_osr) { | 
| 853     CompilationInfoWithZone info(function); | 856     CompilationInfoWithZone info(function); | 
| 854 | 857 | 
| 855     VMState<COMPILER> state(isolate); | 858     VMState<COMPILER> state(isolate); | 
| 856     PostponeInterruptsScope postpone(isolate); | 859     PostponeInterruptsScope postpone(isolate); | 
| 857 | 860 | 
| 858     info.SetOptimizing(BailoutId::None(), handle(function->shared()->code())); | 861     info.SetOptimizing(BailoutId::None(), handle(function->shared()->code())); | 
| 859 | 862 | 
| 860     if (GetOptimizedCodeNow(&info)) { | 863     if (GetOptimizedCodeNow(&info)) { | 
| 861       DCHECK(function->shared()->is_compiled()); | 864       DCHECK(function->shared()->is_compiled()); | 
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1561 } | 1564 } | 
| 1562 | 1565 | 
| 1563 | 1566 | 
| 1564 #if DEBUG | 1567 #if DEBUG | 
| 1565 void CompilationInfo::PrintAstForTesting() { | 1568 void CompilationInfo::PrintAstForTesting() { | 
| 1566   PrintF("--- Source from AST ---\n%s\n", | 1569   PrintF("--- Source from AST ---\n%s\n", | 
| 1567          PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1570          PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 
| 1568 } | 1571 } | 
| 1569 #endif | 1572 #endif | 
| 1570 } }  // namespace v8::internal | 1573 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|