| 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 6532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6543 return kNotInlinable; | 6543 return kNotInlinable; |
| 6544 } | 6544 } |
| 6545 | 6545 |
| 6546 int nodes_added = target_shared->ast_node_count(); | 6546 int nodes_added = target_shared->ast_node_count(); |
| 6547 return nodes_added; | 6547 return nodes_added; |
| 6548 } | 6548 } |
| 6549 | 6549 |
| 6550 | 6550 |
| 6551 bool HGraphBuilder::TryInline(CallKind call_kind, | 6551 bool HGraphBuilder::TryInline(CallKind call_kind, |
| 6552 Handle<JSFunction> target, | 6552 Handle<JSFunction> target, |
| 6553 ZoneList<Expression*>* arguments, | 6553 int arguments_count, |
| 6554 HValue* receiver, | 6554 HValue* receiver, |
| 6555 int ast_id, | 6555 int ast_id, |
| 6556 int return_id, | 6556 int return_id, |
| 6557 ReturnHandlingFlag return_handling) { | 6557 ReturnHandlingFlag return_handling) { |
| 6558 int nodes_added = InliningAstSize(target); | 6558 int nodes_added = InliningAstSize(target); |
| 6559 if (nodes_added == kNotInlinable) return false; | 6559 if (nodes_added == kNotInlinable) return false; |
| 6560 | 6560 |
| 6561 Handle<JSFunction> caller = info()->closure(); | 6561 Handle<JSFunction> caller = info()->closure(); |
| 6562 | 6562 |
| 6563 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { | 6563 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6705 isolate(), | 6705 isolate(), |
| 6706 zone()); | 6706 zone()); |
| 6707 // The function state is new-allocated because we need to delete it | 6707 // The function state is new-allocated because we need to delete it |
| 6708 // in two different places. | 6708 // in two different places. |
| 6709 FunctionState* target_state = new FunctionState( | 6709 FunctionState* target_state = new FunctionState( |
| 6710 this, &target_info, &target_oracle, return_handling); | 6710 this, &target_info, &target_oracle, return_handling); |
| 6711 | 6711 |
| 6712 HConstant* undefined = graph()->GetConstantUndefined(); | 6712 HConstant* undefined = graph()->GetConstantUndefined(); |
| 6713 HEnvironment* inner_env = | 6713 HEnvironment* inner_env = |
| 6714 environment()->CopyForInlining(target, | 6714 environment()->CopyForInlining(target, |
| 6715 arguments->length(), | 6715 arguments_count, |
| 6716 function, | 6716 function, |
| 6717 undefined, | 6717 undefined, |
| 6718 call_kind, | 6718 call_kind, |
| 6719 function_state()->is_construct()); | 6719 function_state()->is_construct()); |
| 6720 #ifdef V8_TARGET_ARCH_IA32 | 6720 #ifdef V8_TARGET_ARCH_IA32 |
| 6721 // IA32 only, overwrite the caller's context in the deoptimization | 6721 // IA32 only, overwrite the caller's context in the deoptimization |
| 6722 // environment with the correct one. | 6722 // environment with the correct one. |
| 6723 // | 6723 // |
| 6724 // TODO(kmillikin): implement the same inlining on other platforms so we | 6724 // TODO(kmillikin): implement the same inlining on other platforms so we |
| 6725 // can remove the unsightly ifdefs in this function. | 6725 // can remove the unsightly ifdefs in this function. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6741 HEnvironment* arguments_env = inner_env->arguments_environment(); | 6741 HEnvironment* arguments_env = inner_env->arguments_environment(); |
| 6742 int arguments_count = arguments_env->parameter_count(); | 6742 int arguments_count = arguments_env->parameter_count(); |
| 6743 arguments_values = new(zone()) ZoneList<HValue*>(arguments_count, zone()); | 6743 arguments_values = new(zone()) ZoneList<HValue*>(arguments_count, zone()); |
| 6744 for (int i = 0; i < arguments_count; i++) { | 6744 for (int i = 0; i < arguments_count; i++) { |
| 6745 arguments_values->Add(arguments_env->Lookup(i), zone()); | 6745 arguments_values->Add(arguments_env->Lookup(i), zone()); |
| 6746 } | 6746 } |
| 6747 } | 6747 } |
| 6748 | 6748 |
| 6749 HEnterInlined* enter_inlined = | 6749 HEnterInlined* enter_inlined = |
| 6750 new(zone()) HEnterInlined(target, | 6750 new(zone()) HEnterInlined(target, |
| 6751 arguments->length(), | 6751 arguments_count, |
| 6752 function, | 6752 function, |
| 6753 call_kind, | 6753 call_kind, |
| 6754 function_state()->is_construct(), | 6754 function_state()->is_construct(), |
| 6755 function->scope()->arguments(), | 6755 function->scope()->arguments(), |
| 6756 arguments_values); | 6756 arguments_values); |
| 6757 function_state()->set_entry(enter_inlined); | 6757 function_state()->set_entry(enter_inlined); |
| 6758 AddInstruction(enter_inlined); | 6758 AddInstruction(enter_inlined); |
| 6759 | 6759 |
| 6760 // If the function uses arguments object create and bind one. | 6760 // If the function uses arguments object create and bind one. |
| 6761 if (function->scope()->arguments() != NULL) { | 6761 if (function->scope()->arguments() != NULL) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6844 | 6844 |
| 6845 bool HGraphBuilder::TryInlineCall(Call* expr, bool drop_extra) { | 6845 bool HGraphBuilder::TryInlineCall(Call* expr, bool drop_extra) { |
| 6846 // The function call we are inlining is a method call if the call | 6846 // The function call we are inlining is a method call if the call |
| 6847 // is a property call. | 6847 // is a property call. |
| 6848 CallKind call_kind = (expr->expression()->AsProperty() == NULL) | 6848 CallKind call_kind = (expr->expression()->AsProperty() == NULL) |
| 6849 ? CALL_AS_FUNCTION | 6849 ? CALL_AS_FUNCTION |
| 6850 : CALL_AS_METHOD; | 6850 : CALL_AS_METHOD; |
| 6851 | 6851 |
| 6852 return TryInline(call_kind, | 6852 return TryInline(call_kind, |
| 6853 expr->target(), | 6853 expr->target(), |
| 6854 expr->arguments(), | 6854 expr->arguments()->length(), |
| 6855 NULL, | 6855 NULL, |
| 6856 expr->id(), | 6856 expr->id(), |
| 6857 expr->ReturnId(), | 6857 expr->ReturnId(), |
| 6858 drop_extra ? DROP_EXTRA_ON_RETURN : NORMAL_RETURN); | 6858 drop_extra ? DROP_EXTRA_ON_RETURN : NORMAL_RETURN); |
| 6859 } | 6859 } |
| 6860 | 6860 |
| 6861 | 6861 |
| 6862 bool HGraphBuilder::TryInlineConstruct(CallNew* expr, HValue* receiver) { | 6862 bool HGraphBuilder::TryInlineConstruct(CallNew* expr, HValue* receiver) { |
| 6863 return TryInline(CALL_AS_FUNCTION, | 6863 return TryInline(CALL_AS_FUNCTION, |
| 6864 expr->target(), | 6864 expr->target(), |
| 6865 expr->arguments(), | 6865 expr->arguments()->length(), |
| 6866 receiver, | 6866 receiver, |
| 6867 expr->id(), | 6867 expr->id(), |
| 6868 expr->ReturnId(), | 6868 expr->ReturnId(), |
| 6869 CONSTRUCT_CALL_RETURN); | 6869 CONSTRUCT_CALL_RETURN); |
| 6870 } | 6870 } |
| 6871 | 6871 |
| 6872 | 6872 |
| 6873 bool HGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra) { | 6873 bool HGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra) { |
| 6874 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; | 6874 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; |
| 6875 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); | 6875 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); |
| (...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9573 } | 9573 } |
| 9574 } | 9574 } |
| 9575 | 9575 |
| 9576 #ifdef DEBUG | 9576 #ifdef DEBUG |
| 9577 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 9577 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 9578 if (allocator_ != NULL) allocator_->Verify(); | 9578 if (allocator_ != NULL) allocator_->Verify(); |
| 9579 #endif | 9579 #endif |
| 9580 } | 9580 } |
| 9581 | 9581 |
| 9582 } } // namespace v8::internal | 9582 } } // namespace v8::internal |
| OLD | NEW |