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