 Chromium Code Reviews
 Chromium Code Reviews Issue 2274253003:
  [compiler] Don't canonicalize handles in Crankshaft.  (Closed)
    
  
    Issue 2274253003:
  [compiler] Don't canonicalize handles in Crankshaft.  (Closed) 
  | 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 } | 691 } | 
| 692 | 692 | 
| 693 // Success! | 693 // Success! | 
| 694 job->RecordOptimizationStats(); | 694 job->RecordOptimizationStats(); | 
| 695 DCHECK(!isolate->has_pending_exception()); | 695 DCHECK(!isolate->has_pending_exception()); | 
| 696 InsertCodeIntoOptimizedCodeMap(info); | 696 InsertCodeIntoOptimizedCodeMap(info); | 
| 697 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); | 697 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); | 
| 698 return true; | 698 return true; | 
| 699 } | 699 } | 
| 700 | 700 | 
| 701 bool GetOptimizedCodeLater(CompilationJob* job) { | 701 bool GetOptimizedCodeLater(CompilationJob* job, bool use_turbofan) { | 
| 702 CompilationInfo* info = job->info(); | 702 CompilationInfo* info = job->info(); | 
| 703 Isolate* isolate = info->isolate(); | 703 Isolate* isolate = info->isolate(); | 
| 704 | 704 | 
| 705 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { | 705 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { | 
| 706 if (FLAG_trace_concurrent_recompilation) { | 706 if (FLAG_trace_concurrent_recompilation) { | 
| 707 PrintF(" ** Compilation queue full, will retry optimizing "); | 707 PrintF(" ** Compilation queue full, will retry optimizing "); | 
| 708 info->closure()->ShortPrint(); | 708 info->closure()->ShortPrint(); | 
| 709 PrintF(" later.\n"); | 709 PrintF(" later.\n"); | 
| 710 } | 710 } | 
| 711 return false; | 711 return false; | 
| 712 } | 712 } | 
| 713 | 713 | 
| 714 if (isolate->heap()->HighMemoryPressure()) { | 714 if (isolate->heap()->HighMemoryPressure()) { | 
| 715 if (FLAG_trace_concurrent_recompilation) { | 715 if (FLAG_trace_concurrent_recompilation) { | 
| 716 PrintF(" ** High memory pressure, will retry optimizing "); | 716 PrintF(" ** High memory pressure, will retry optimizing "); | 
| 717 info->closure()->ShortPrint(); | 717 info->closure()->ShortPrint(); | 
| 718 PrintF(" later.\n"); | 718 PrintF(" later.\n"); | 
| 719 } | 719 } | 
| 720 return false; | 720 return false; | 
| 721 } | 721 } | 
| 722 | 722 | 
| 723 // All handles below this point will be canonicalized and allocated in a | 723 // All handles below this point will be canonicalized and allocated in a | 
| 724 // deferred handle scope that is detached and handed off to the background | 724 // deferred handle scope that is detached and handed off to the background | 
| 725 // thread when we return. | 725 // thread when we return. | 
| 726 CompilationHandleScope handle_scope(info); | 726 CompilationHandleScope handle_scope(info); | 
| 
Michael Starzinger
2016/08/25 11:44:20
Would it be possible to hoist both, the Compilatio
 | |
| 727 CanonicalHandleScope canonical(isolate); | 727 std::unique_ptr<CanonicalHandleScope> canonical; | 
| 728 if (use_turbofan) canonical.reset(new CanonicalHandleScope(info->isolate())); | |
| 728 | 729 | 
| 729 // Parsing is not required when optimizing from existing bytecode. | 730 // Parsing is not required when optimizing from existing bytecode. | 
| 730 if (!info->is_optimizing_from_bytecode()) { | 731 if (!info->is_optimizing_from_bytecode()) { | 
| 731 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; | 732 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; | 
| 732 EnsureFeedbackMetadata(info); | 733 EnsureFeedbackMetadata(info); | 
| 733 } | 734 } | 
| 734 | 735 | 
| 735 JSFunction::EnsureLiterals(info->closure()); | 736 JSFunction::EnsureLiterals(info->closure()); | 
| 736 | 737 | 
| 737 // Reopen handles in the new CompilationHandleScope. | 738 // Reopen handles in the new CompilationHandleScope. | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 833 | 834 | 
| 834 if (IsEvalToplevel(shared)) { | 835 if (IsEvalToplevel(shared)) { | 
| 835 parse_info->set_eval(); | 836 parse_info->set_eval(); | 
| 836 if (function->context()->IsNativeContext()) parse_info->set_global(); | 837 if (function->context()->IsNativeContext()) parse_info->set_global(); | 
| 837 parse_info->set_toplevel(); | 838 parse_info->set_toplevel(); | 
| 838 parse_info->set_allow_lazy_parsing(false); | 839 parse_info->set_allow_lazy_parsing(false); | 
| 839 parse_info->set_lazy(false); | 840 parse_info->set_lazy(false); | 
| 840 } | 841 } | 
| 841 | 842 | 
| 842 if (mode == Compiler::CONCURRENT) { | 843 if (mode == Compiler::CONCURRENT) { | 
| 843 if (GetOptimizedCodeLater(job.get())) { | 844 if (GetOptimizedCodeLater(job.get(), use_turbofan)) { | 
| 844 job.release(); // The background recompile job owns this now. | 845 job.release(); // The background recompile job owns this now. | 
| 845 return isolate->builtins()->InOptimizationQueue(); | 846 return isolate->builtins()->InOptimizationQueue(); | 
| 846 } | 847 } | 
| 847 } else { | 848 } else { | 
| 848 if (GetOptimizedCodeNow(job.get())) return info->code(); | 849 if (GetOptimizedCodeNow(job.get())) return info->code(); | 
| 849 } | 850 } | 
| 850 | 851 | 
| 851 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); | 852 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); | 
| 852 return MaybeHandle<Code>(); | 853 return MaybeHandle<Code>(); | 
| 853 } | 854 } | 
| (...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1985 DCHECK(shared->is_compiled()); | 1986 DCHECK(shared->is_compiled()); | 
| 1986 function->set_literals(cached.literals); | 1987 function->set_literals(cached.literals); | 
| 1987 } else if (shared->is_compiled()) { | 1988 } else if (shared->is_compiled()) { | 
| 1988 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1989 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 
| 1989 JSFunction::EnsureLiterals(function); | 1990 JSFunction::EnsureLiterals(function); | 
| 1990 } | 1991 } | 
| 1991 } | 1992 } | 
| 1992 | 1993 | 
| 1993 } // namespace internal | 1994 } // namespace internal | 
| 1994 } // namespace v8 | 1995 } // namespace v8 | 
| OLD | NEW |