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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 if (info()->osr_frame()) info()->MarkAsFrameSpecializing(); | 438 if (info()->osr_frame()) info()->MarkAsFrameSpecializing(); |
439 info()->MarkAsFunctionContextSpecializing(); | 439 info()->MarkAsFunctionContextSpecializing(); |
440 } else if (FLAG_turbo_type_feedback) { | 440 } else if (FLAG_turbo_type_feedback) { |
441 info()->MarkAsTypeFeedbackEnabled(); | 441 info()->MarkAsTypeFeedbackEnabled(); |
442 info()->EnsureFeedbackVector(); | 442 info()->EnsureFeedbackVector(); |
443 } | 443 } |
444 if (!info()->shared_info()->asm_function() || | 444 if (!info()->shared_info()->asm_function() || |
445 FLAG_turbo_asm_deoptimization) { | 445 FLAG_turbo_asm_deoptimization) { |
446 info()->MarkAsDeoptimizationEnabled(); | 446 info()->MarkAsDeoptimizationEnabled(); |
447 } | 447 } |
| 448 if (info()->has_global_object() && FLAG_native_context_specialization) { |
| 449 info()->MarkAsNativeContextSpecializing(); |
| 450 } |
448 | 451 |
449 Timer t(this, &time_taken_to_create_graph_); | 452 Timer t(this, &time_taken_to_create_graph_); |
450 compiler::Pipeline pipeline(info()); | 453 compiler::Pipeline pipeline(info()); |
451 pipeline.GenerateCode(); | 454 pipeline.GenerateCode(); |
452 if (!info()->code().is_null()) { | 455 if (!info()->code().is_null()) { |
453 return SetLastStatus(SUCCEEDED); | 456 return SetLastStatus(SUCCEEDED); |
454 } | 457 } |
455 } | 458 } |
456 | 459 |
457 if (!isolate()->use_crankshaft() || dont_crankshaft) { | 460 if (!isolate()->use_crankshaft() || dont_crankshaft) { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 return Handle<Code>(cached.code); | 768 return Handle<Code>(cached.code); |
766 } | 769 } |
767 return MaybeHandle<Code>(); | 770 return MaybeHandle<Code>(); |
768 } | 771 } |
769 | 772 |
770 | 773 |
771 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { | 774 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
772 Handle<Code> code = info->code(); | 775 Handle<Code> code = info->code(); |
773 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. | 776 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. |
774 | 777 |
775 // Context specialization folds-in the context, so no sharing can occur. | 778 // Function context specialization folds-in the function context, |
| 779 // so no sharing can occur. |
776 if (info->is_function_context_specializing()) return; | 780 if (info->is_function_context_specializing()) return; |
777 // Frame specialization implies function context specialization. | 781 // Frame specialization implies function context specialization. |
778 DCHECK(!info->is_frame_specializing()); | 782 DCHECK(!info->is_frame_specializing()); |
779 | 783 |
780 // Do not cache bound functions. | 784 // Do not cache bound functions. |
781 Handle<JSFunction> function = info->closure(); | 785 Handle<JSFunction> function = info->closure(); |
782 if (function->shared()->bound()) return; | 786 if (function->shared()->bound()) return; |
783 | 787 |
784 // Cache optimized context-specific code. | 788 // Cache optimized context-specific code. |
785 if (FLAG_cache_optimized_code) { | 789 if (FLAG_cache_optimized_code) { |
786 Handle<SharedFunctionInfo> shared(function->shared()); | 790 Handle<SharedFunctionInfo> shared(function->shared()); |
787 Handle<LiteralsArray> literals(function->literals()); | 791 Handle<LiteralsArray> literals(function->literals()); |
788 Handle<Context> native_context(function->context()->native_context()); | 792 Handle<Context> native_context(function->context()->native_context()); |
789 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 793 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
790 literals, info->osr_ast_id()); | 794 literals, info->osr_ast_id()); |
791 } | 795 } |
792 | 796 |
793 // Do not cache context-independent code compiled for OSR. | 797 // Do not cache (native) context-independent code compiled for OSR. |
794 if (code->is_turbofanned() && info->is_osr()) return; | 798 if (code->is_turbofanned() && info->is_osr()) return; |
795 | 799 |
796 // Cache optimized context-independent code. | 800 // Cache optimized (native) context-independent code. |
797 if (FLAG_turbo_cache_shared_code && code->is_turbofanned()) { | 801 if (FLAG_turbo_cache_shared_code && code->is_turbofanned() && |
| 802 !info->is_native_context_specializing()) { |
798 DCHECK(!info->is_function_context_specializing()); | 803 DCHECK(!info->is_function_context_specializing()); |
799 DCHECK(info->osr_ast_id().IsNone()); | 804 DCHECK(info->osr_ast_id().IsNone()); |
800 Handle<SharedFunctionInfo> shared(function->shared()); | 805 Handle<SharedFunctionInfo> shared(function->shared()); |
801 SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(shared, code); | 806 SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(shared, code); |
802 } | 807 } |
803 } | 808 } |
804 | 809 |
805 | 810 |
806 static bool Renumber(ParseInfo* parse_info) { | 811 static bool Renumber(ParseInfo* parse_info) { |
807 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(), | 812 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(), |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 } | 1762 } |
1758 | 1763 |
1759 #if DEBUG | 1764 #if DEBUG |
1760 void CompilationInfo::PrintAstForTesting() { | 1765 void CompilationInfo::PrintAstForTesting() { |
1761 PrintF("--- Source from AST ---\n%s\n", | 1766 PrintF("--- Source from AST ---\n%s\n", |
1762 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); | 1767 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); |
1763 } | 1768 } |
1764 #endif | 1769 #endif |
1765 } // namespace internal | 1770 } // namespace internal |
1766 } // namespace v8 | 1771 } // namespace v8 |
OLD | NEW |