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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 // Update the code and feedback vector for the shared function info. | 681 // Update the code and feedback vector for the shared function info. |
682 shared->ReplaceCode(*info->code()); | 682 shared->ReplaceCode(*info->code()); |
683 shared->set_feedback_vector(*info->feedback_vector()); | 683 shared->set_feedback_vector(*info->feedback_vector()); |
684 | 684 |
685 return info->code(); | 685 return info->code(); |
686 } | 686 } |
687 | 687 |
688 | 688 |
689 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( | 689 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( |
690 Handle<JSFunction> function, BailoutId osr_ast_id) { | 690 Handle<JSFunction> function, BailoutId osr_ast_id) { |
691 if (FLAG_cache_optimized_code) { | 691 Handle<SharedFunctionInfo> shared(function->shared()); |
692 Handle<SharedFunctionInfo> shared(function->shared()); | 692 DisallowHeapAllocation no_gc; |
693 DisallowHeapAllocation no_gc; | 693 CodeAndLiterals cached = shared->SearchOptimizedCodeMap( |
694 CodeAndLiterals cached = shared->SearchOptimizedCodeMap( | 694 function->context()->native_context(), osr_ast_id); |
695 function->context()->native_context(), osr_ast_id); | 695 if (cached.code != nullptr) { |
696 if (cached.code != nullptr) { | 696 // Caching of optimized code enabled and optimized code found. |
697 // Caching of optimized code enabled and optimized code found. | 697 if (cached.literals != nullptr) function->set_literals(cached.literals); |
698 if (cached.literals != nullptr) function->set_literals(cached.literals); | 698 DCHECK(!cached.code->marked_for_deoptimization()); |
699 DCHECK(!cached.code->marked_for_deoptimization()); | 699 DCHECK(function->shared()->is_compiled()); |
700 DCHECK(function->shared()->is_compiled()); | 700 return Handle<Code>(cached.code); |
701 return Handle<Code>(cached.code); | |
702 } | |
703 } | 701 } |
704 return MaybeHandle<Code>(); | 702 return MaybeHandle<Code>(); |
705 } | 703 } |
706 | 704 |
707 | 705 |
708 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { | 706 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
709 Handle<Code> code = info->code(); | 707 Handle<Code> code = info->code(); |
710 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. | 708 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. |
711 | 709 |
712 // Context specialization folds-in the context, so no sharing can occur. | 710 // Context specialization folds-in the context, so no sharing can occur. |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 | 1564 |
1567 | 1565 |
1568 #if DEBUG | 1566 #if DEBUG |
1569 void CompilationInfo::PrintAstForTesting() { | 1567 void CompilationInfo::PrintAstForTesting() { |
1570 PrintF("--- Source from AST ---\n%s\n", | 1568 PrintF("--- Source from AST ---\n%s\n", |
1571 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1569 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
1572 } | 1570 } |
1573 #endif | 1571 #endif |
1574 } // namespace internal | 1572 } // namespace internal |
1575 } // namespace v8 | 1573 } // namespace v8 |
OLD | NEW |