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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 bool is_optimizable_closure = | 103 bool is_optimizable_closure = |
104 FLAG_optimize_closures && | 104 FLAG_optimize_closures && |
105 closure_.is_null() && | 105 closure_.is_null() && |
106 !scope_->HasTrivialOuterContext() && | 106 !scope_->HasTrivialOuterContext() && |
107 !scope_->outer_scope_calls_non_strict_eval() && | 107 !scope_->outer_scope_calls_non_strict_eval() && |
108 !scope_->inside_with(); | 108 !scope_->inside_with(); |
109 SetMode(is_optimizable_closure ? BASE : NONOPT); | 109 SetMode(is_optimizable_closure ? BASE : NONOPT); |
110 } | 110 } |
111 | 111 |
112 | 112 |
| 113 // Primitive functions are unlikely to be picked up by the stack-walking |
| 114 // profiler, so they trigger their own optimization when they're called |
| 115 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. |
| 116 bool CompilationInfo::ShouldSelfOptimize() { |
| 117 return FLAG_counting_profiler && |
| 118 FLAG_crankshaft && |
| 119 !Serializer::enabled() && |
| 120 !function()->flags()->Contains(kDontSelfOptimize) && |
| 121 (shared_info().is_null() || !shared_info()->optimization_disabled()); |
| 122 } |
| 123 |
| 124 |
113 void CompilationInfo::AbortOptimization() { | 125 void CompilationInfo::AbortOptimization() { |
114 Handle<Code> code(shared_info()->code()); | 126 Handle<Code> code(shared_info()->code()); |
115 SetCode(code); | 127 SetCode(code); |
116 } | 128 } |
117 | 129 |
118 | 130 |
119 // Determine whether to use the full compiler for all code. If the flag | 131 // Determine whether to use the full compiler for all code. If the flag |
120 // --always-full-compiler is specified this is the case. For the virtual frame | 132 // --always-full-compiler is specified this is the case. For the virtual frame |
121 // based compiler the full compiler is also used if a debugger is connected, as | 133 // based compiler the full compiler is also used if a debugger is connected, as |
122 // the code from the full compiler supports mode precise break points. For the | 134 // the code from the full compiler supports mode precise break points. For the |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 // compiled function. | 659 // compiled function. |
648 shared->SetThisPropertyAssignmentsInfo( | 660 shared->SetThisPropertyAssignmentsInfo( |
649 lit->has_only_simple_this_property_assignments(), | 661 lit->has_only_simple_this_property_assignments(), |
650 *lit->this_property_assignments()); | 662 *lit->this_property_assignments()); |
651 | 663 |
652 // Check the function has compiled code. | 664 // Check the function has compiled code. |
653 ASSERT(shared->is_compiled()); | 665 ASSERT(shared->is_compiled()); |
654 shared->set_code_age(0); | 666 shared->set_code_age(0); |
655 shared->set_dont_crankshaft(lit->flags()->Contains(kDontOptimize)); | 667 shared->set_dont_crankshaft(lit->flags()->Contains(kDontOptimize)); |
656 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); | 668 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); |
| 669 shared->set_ast_node_count(lit->ast_node_count()); |
657 | 670 |
658 if (info->AllowOptimize() && !shared->optimization_disabled()) { | 671 if (info->AllowOptimize() && !shared->optimization_disabled()) { |
659 // If we're asked to always optimize, we compile the optimized | 672 // If we're asked to always optimize, we compile the optimized |
660 // version of the function right away - unless the debugger is | 673 // version of the function right away - unless the debugger is |
661 // active as it makes no sense to compile optimized code then. | 674 // active as it makes no sense to compile optimized code then. |
662 if (FLAG_always_opt && | 675 if (FLAG_always_opt && |
663 !Isolate::Current()->DebuggerHasBreakPoints()) { | 676 !Isolate::Current()->DebuggerHasBreakPoints()) { |
664 CompilationInfo optimized(function); | 677 CompilationInfo optimized(function); |
665 optimized.SetOptimizing(AstNode::kNoNumber); | 678 optimized.SetOptimizing(AstNode::kNoNumber); |
666 return CompileLazy(&optimized); | 679 return CompileLazy(&optimized); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 } | 804 } |
792 } | 805 } |
793 | 806 |
794 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 807 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
795 Handle<Script>(info->script()), | 808 Handle<Script>(info->script()), |
796 Handle<Code>(info->code()), | 809 Handle<Code>(info->code()), |
797 info)); | 810 info)); |
798 } | 811 } |
799 | 812 |
800 } } // namespace v8::internal | 813 } } // namespace v8::internal |
OLD | NEW |