OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 CompilationInfo::CompilationInfo(Handle<Script> script) | 54 CompilationInfo::CompilationInfo(Handle<Script> script) |
55 : isolate_(script->GetIsolate()), | 55 : isolate_(script->GetIsolate()), |
56 flags_(LanguageModeField::encode(CLASSIC_MODE)), | 56 flags_(LanguageModeField::encode(CLASSIC_MODE)), |
57 function_(NULL), | 57 function_(NULL), |
58 scope_(NULL), | 58 scope_(NULL), |
59 global_scope_(NULL), | 59 global_scope_(NULL), |
60 script_(script), | 60 script_(script), |
61 extension_(NULL), | 61 extension_(NULL), |
62 pre_parse_data_(NULL), | 62 pre_parse_data_(NULL), |
63 osr_ast_id_(AstNode::kNoNumber) { | 63 osr_ast_id_(AstNode::kNoNumber) { |
64 Initialize(NONOPT); | 64 Initialize(BASE); |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info) | 68 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info) |
69 : isolate_(shared_info->GetIsolate()), | 69 : isolate_(shared_info->GetIsolate()), |
70 flags_(LanguageModeField::encode(CLASSIC_MODE) | | 70 flags_(LanguageModeField::encode(CLASSIC_MODE) | |
71 IsLazy::encode(true)), | 71 IsLazy::encode(true)), |
72 function_(NULL), | 72 function_(NULL), |
73 scope_(NULL), | 73 scope_(NULL), |
74 global_scope_(NULL), | 74 global_scope_(NULL), |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 compiled_functions, | 175 compiled_functions, |
176 code_size, | 176 code_size, |
177 compilation_time); | 177 compilation_time); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 static bool MakeCrankshaftCode(CompilationInfo* info) { | 182 static bool MakeCrankshaftCode(CompilationInfo* info) { |
183 // Test if we can optimize this function when asked to. We can only | 183 // Test if we can optimize this function when asked to. We can only |
184 // do this after the scopes are computed. | 184 // do this after the scopes are computed. |
185 if (!info->AllowOptimize()) { | 185 if (!V8::UseCrankshaft()) { |
186 info->DisableOptimization(); | 186 info->DisableOptimization(); |
187 } else if (info->IsOptimizable()) { | |
188 info->EnableDeoptimizationSupport(); | |
189 } | 187 } |
190 | 188 |
191 // In case we are not optimizing simply return the code from | 189 // In case we are not optimizing simply return the code from |
192 // the full code generator. | 190 // the full code generator. |
193 if (!info->IsOptimizing()) { | 191 if (!info->IsOptimizing()) { |
194 return FullCodeGenerator::MakeCode(info); | 192 return FullCodeGenerator::MakeCode(info); |
195 } | 193 } |
196 | 194 |
197 // We should never arrive here if there is not code object on the | 195 // We should never arrive here if there is not code object on the |
198 // shared function object. | 196 // shared function object. |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 // Set the optimization hints after performing lazy compilation, as | 655 // Set the optimization hints after performing lazy compilation, as |
658 // these are not set when the function is set up as a lazily | 656 // these are not set when the function is set up as a lazily |
659 // compiled function. | 657 // compiled function. |
660 shared->SetThisPropertyAssignmentsInfo( | 658 shared->SetThisPropertyAssignmentsInfo( |
661 lit->has_only_simple_this_property_assignments(), | 659 lit->has_only_simple_this_property_assignments(), |
662 *lit->this_property_assignments()); | 660 *lit->this_property_assignments()); |
663 | 661 |
664 // Check the function has compiled code. | 662 // Check the function has compiled code. |
665 ASSERT(shared->is_compiled()); | 663 ASSERT(shared->is_compiled()); |
666 shared->set_code_age(0); | 664 shared->set_code_age(0); |
667 shared->set_dont_crankshaft(lit->flags()->Contains(kDontOptimize)); | 665 shared->set_dont_optimize(lit->flags()->Contains(kDontOptimize)); |
668 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); | 666 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); |
669 shared->set_ast_node_count(lit->ast_node_count()); | 667 shared->set_ast_node_count(lit->ast_node_count()); |
670 | 668 |
671 if (info->AllowOptimize() && !shared->optimization_disabled()) { | 669 if (V8::UseCrankshaft()&& |
| 670 !function.is_null() && |
| 671 !shared->optimization_disabled()) { |
672 // If we're asked to always optimize, we compile the optimized | 672 // If we're asked to always optimize, we compile the optimized |
673 // version of the function right away - unless the debugger is | 673 // version of the function right away - unless the debugger is |
674 // active as it makes no sense to compile optimized code then. | 674 // active as it makes no sense to compile optimized code then. |
675 if (FLAG_always_opt && | 675 if (FLAG_always_opt && |
676 !Isolate::Current()->DebuggerHasBreakPoints()) { | 676 !Isolate::Current()->DebuggerHasBreakPoints()) { |
677 CompilationInfo optimized(function); | 677 CompilationInfo optimized(function); |
678 optimized.SetOptimizing(AstNode::kNoNumber); | 678 optimized.SetOptimizing(AstNode::kNoNumber); |
679 return CompileLazy(&optimized); | 679 return CompileLazy(&optimized); |
680 } | 680 } |
681 } | 681 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 function_info->set_is_toplevel(is_toplevel); | 759 function_info->set_is_toplevel(is_toplevel); |
760 function_info->set_inferred_name(*lit->inferred_name()); | 760 function_info->set_inferred_name(*lit->inferred_name()); |
761 function_info->SetThisPropertyAssignmentsInfo( | 761 function_info->SetThisPropertyAssignmentsInfo( |
762 lit->has_only_simple_this_property_assignments(), | 762 lit->has_only_simple_this_property_assignments(), |
763 *lit->this_property_assignments()); | 763 *lit->this_property_assignments()); |
764 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); | 764 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); |
765 function_info->set_language_mode(lit->language_mode()); | 765 function_info->set_language_mode(lit->language_mode()); |
766 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); | 766 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); |
767 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); | 767 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); |
768 function_info->set_ast_node_count(lit->ast_node_count()); | 768 function_info->set_ast_node_count(lit->ast_node_count()); |
769 function_info->set_dont_crankshaft(lit->flags()->Contains(kDontOptimize)); | 769 function_info->set_is_function(lit->is_function()); |
| 770 function_info->set_dont_optimize(lit->flags()->Contains(kDontOptimize)); |
770 function_info->set_dont_inline(lit->flags()->Contains(kDontInline)); | 771 function_info->set_dont_inline(lit->flags()->Contains(kDontInline)); |
771 } | 772 } |
772 | 773 |
773 | 774 |
774 void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 775 void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
775 CompilationInfo* info, | 776 CompilationInfo* info, |
776 Handle<SharedFunctionInfo> shared) { | 777 Handle<SharedFunctionInfo> shared) { |
777 // SharedFunctionInfo is passed separately, because if CompilationInfo | 778 // SharedFunctionInfo is passed separately, because if CompilationInfo |
778 // was created using Script object, it will not have it. | 779 // was created using Script object, it will not have it. |
779 | 780 |
(...skipping 24 matching lines...) Expand all Loading... |
804 } | 805 } |
805 } | 806 } |
806 | 807 |
807 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 808 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
808 Handle<Script>(info->script()), | 809 Handle<Script>(info->script()), |
809 Handle<Code>(info->code()), | 810 Handle<Code>(info->code()), |
810 info)); | 811 info)); |
811 } | 812 } |
812 | 813 |
813 } } // namespace v8::internal | 814 } } // namespace v8::internal |
OLD | NEW |