OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
(...skipping 5651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5662 | 5662 |
5663 void HOptimizedGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { | 5663 void HOptimizedGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { |
5664 DCHECK(!HasStackOverflow()); | 5664 DCHECK(!HasStackOverflow()); |
5665 DCHECK(current_block() != NULL); | 5665 DCHECK(current_block() != NULL); |
5666 DCHECK(current_block()->HasPredecessor()); | 5666 DCHECK(current_block()->HasPredecessor()); |
5667 Handle<SharedFunctionInfo> shared_info = Compiler::GetSharedFunctionInfo( | 5667 Handle<SharedFunctionInfo> shared_info = Compiler::GetSharedFunctionInfo( |
5668 expr, current_info()->script(), top_info()); | 5668 expr, current_info()->script(), top_info()); |
5669 // We also have a stack overflow if the recursive compilation did. | 5669 // We also have a stack overflow if the recursive compilation did. |
5670 if (HasStackOverflow()) return; | 5670 if (HasStackOverflow()) return; |
5671 // Use the fast case closure allocation code that allocates in new | 5671 // Use the fast case closure allocation code that allocates in new |
5672 // space for nested functions that don't need literals cloning. | 5672 // space for nested functions that don't need pretenuring. |
5673 HConstant* shared_info_value = Add<HConstant>(shared_info); | 5673 HConstant* shared_info_value = Add<HConstant>(shared_info); |
5674 HInstruction* instr; | 5674 HInstruction* instr; |
5675 if (!expr->pretenure() && shared_info->num_literals() == 0) { | 5675 if (!expr->pretenure()) { |
5676 FastNewClosureStub stub(isolate(), shared_info->language_mode(), | 5676 FastNewClosureStub stub(isolate(), shared_info->language_mode(), |
5677 shared_info->kind()); | 5677 shared_info->kind()); |
5678 FastNewClosureDescriptor descriptor(isolate()); | 5678 FastNewClosureDescriptor descriptor(isolate()); |
5679 HValue* values[] = {context(), shared_info_value}; | 5679 HValue* values[] = {context(), shared_info_value}; |
5680 HConstant* stub_value = Add<HConstant>(stub.GetCode()); | 5680 HConstant* stub_value = Add<HConstant>(stub.GetCode()); |
5681 instr = New<HCallWithDescriptor>(stub_value, 0, descriptor, | 5681 instr = New<HCallWithDescriptor>(stub_value, 0, descriptor, |
5682 ArrayVector(values)); | 5682 ArrayVector(values)); |
5683 } else { | 5683 } else { |
5684 Add<HPushArguments>(shared_info_value); | 5684 Add<HPushArguments>(shared_info_value); |
5685 Runtime::FunctionId function_id = | 5685 Runtime::FunctionId function_id = |
(...skipping 2935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8621 return false; | 8621 return false; |
8622 } | 8622 } |
8623 } | 8623 } |
8624 | 8624 |
8625 // Generate the deoptimization data for the unoptimized version of | 8625 // Generate the deoptimization data for the unoptimized version of |
8626 // the target function if we don't already have it. | 8626 // the target function if we don't already have it. |
8627 if (!Compiler::EnsureDeoptimizationSupport(&target_info)) { | 8627 if (!Compiler::EnsureDeoptimizationSupport(&target_info)) { |
8628 TraceInline(target, caller, "could not generate deoptimization info"); | 8628 TraceInline(target, caller, "could not generate deoptimization info"); |
8629 return false; | 8629 return false; |
8630 } | 8630 } |
| 8631 |
8631 // Remember that we inlined this function. This needs to be called right | 8632 // Remember that we inlined this function. This needs to be called right |
8632 // after the EnsureDeoptimizationSupport call so that the code flusher | 8633 // after the EnsureDeoptimizationSupport call so that the code flusher |
8633 // does not remove the code with the deoptimization support. | 8634 // does not remove the code with the deoptimization support. |
8634 top_info()->AddInlinedFunction(target_info.shared_info()); | 8635 top_info()->AddInlinedFunction(target_info.shared_info()); |
8635 | 8636 |
8636 // ---------------------------------------------------------------- | 8637 // ---------------------------------------------------------------- |
8637 // After this point, we've made a decision to inline this function (so | 8638 // After this point, we've made a decision to inline this function (so |
8638 // TryInline should always return true). | 8639 // TryInline should always return true). |
8639 | 8640 |
| 8641 // If target was lazily compiled, it's literals array may not yet be set up. |
| 8642 JSFunction::EnsureLiterals(target); |
| 8643 |
8640 // Type-check the inlined function. | 8644 // Type-check the inlined function. |
8641 DCHECK(target_shared->has_deoptimization_support()); | 8645 DCHECK(target_shared->has_deoptimization_support()); |
8642 AstTyper(target_info.isolate(), target_info.zone(), target_info.closure(), | 8646 AstTyper(target_info.isolate(), target_info.zone(), target_info.closure(), |
8643 target_info.scope(), target_info.osr_ast_id(), target_info.literal(), | 8647 target_info.scope(), target_info.osr_ast_id(), target_info.literal(), |
8644 &bounds_) | 8648 &bounds_) |
8645 .Run(); | 8649 .Run(); |
8646 | 8650 |
8647 int inlining_id = 0; | 8651 int inlining_id = 0; |
8648 if (top_info()->is_tracking_positions()) { | 8652 if (top_info()->is_tracking_positions()) { |
8649 inlining_id = TraceInlinedFunction(target_shared, source_position()); | 8653 inlining_id = TraceInlinedFunction(target_shared, source_position()); |
(...skipping 5047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13697 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13701 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13698 } | 13702 } |
13699 | 13703 |
13700 #ifdef DEBUG | 13704 #ifdef DEBUG |
13701 graph_->Verify(false); // No full verify. | 13705 graph_->Verify(false); // No full verify. |
13702 #endif | 13706 #endif |
13703 } | 13707 } |
13704 | 13708 |
13705 } // namespace internal | 13709 } // namespace internal |
13706 } // namespace v8 | 13710 } // namespace v8 |
OLD | NEW |