Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: src/hydrogen.cc

Issue 8341019: Fix bug in inlining call-as-function when inlining multiple levels deep. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | test/mjsunit/compiler/regress-inline-callfunctionstub.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 4692 matching lines...) Expand 10 before | Expand all | Expand 10 after
4703 // After this point, we've made a decision to inline this function (so 4703 // After this point, we've made a decision to inline this function (so
4704 // TryInline should always return true). 4704 // TryInline should always return true).
4705 4705
4706 // Save the pending call context and type feedback oracle. Set up new ones 4706 // Save the pending call context and type feedback oracle. Set up new ones
4707 // for the inlined function. 4707 // for the inlined function.
4708 ASSERT(target_shared->has_deoptimization_support()); 4708 ASSERT(target_shared->has_deoptimization_support());
4709 TypeFeedbackOracle target_oracle( 4709 TypeFeedbackOracle target_oracle(
4710 Handle<Code>(target_shared->code()), 4710 Handle<Code>(target_shared->code()),
4711 Handle<Context>(target->context()->global_context()), 4711 Handle<Context>(target->context()->global_context()),
4712 isolate()); 4712 isolate());
4713 FunctionState target_state(this, &target_info, &target_oracle, drop_extra); 4713 // The function state is new-allocated because we need to delete it
4714 // in two different places.
4715 FunctionState* target_state =
4716 new FunctionState(this, &target_info, &target_oracle, drop_extra);
4714 4717
4715 HConstant* undefined = graph()->GetConstantUndefined(); 4718 HConstant* undefined = graph()->GetConstantUndefined();
4716 HEnvironment* inner_env = 4719 HEnvironment* inner_env =
4717 environment()->CopyForInlining(target, 4720 environment()->CopyForInlining(target,
4718 function, 4721 function,
4719 undefined, 4722 undefined,
4720 call_kind); 4723 call_kind);
4721 #ifdef V8_TARGET_ARCH_IA32 4724 #ifdef V8_TARGET_ARCH_IA32
4722 // IA32 only, overwrite the caller's context in the deoptimization 4725 // IA32 only, overwrite the caller's context in the deoptimization
4723 // environment with the correct one. 4726 // environment with the correct one.
(...skipping 13 matching lines...) Expand all
4737 function, 4740 function,
4738 call_kind)); 4741 call_kind));
4739 VisitDeclarations(target_info.scope()->declarations()); 4742 VisitDeclarations(target_info.scope()->declarations());
4740 VisitStatements(function->body()); 4743 VisitStatements(function->body());
4741 if (HasStackOverflow()) { 4744 if (HasStackOverflow()) {
4742 // Bail out if the inline function did, as we cannot residualize a call 4745 // Bail out if the inline function did, as we cannot residualize a call
4743 // instead. 4746 // instead.
4744 TraceInline(target, caller, "inline graph construction failed"); 4747 TraceInline(target, caller, "inline graph construction failed");
4745 target_shared->DisableOptimization(*target); 4748 target_shared->DisableOptimization(*target);
4746 inline_bailout_ = true; 4749 inline_bailout_ = true;
4750 delete target_state;
4747 return true; 4751 return true;
4748 } 4752 }
4749 4753
4750 // Update inlined nodes count. 4754 // Update inlined nodes count.
4751 inlined_count_ += nodes_added; 4755 inlined_count_ += nodes_added;
4752 4756
4753 TraceInline(target, caller, NULL); 4757 TraceInline(target, caller, NULL);
4754 4758
4755 if (current_block() != NULL) { 4759 if (current_block() != NULL) {
4756 // Add a return of undefined if control can fall off the body. In a 4760 // Add a return of undefined if control can fall off the body. In a
(...skipping 26 matching lines...) Expand all
4783 } 4787 }
4784 4788
4785 // Fix up the function exits. 4789 // Fix up the function exits.
4786 if (inlined_test_context() != NULL) { 4790 if (inlined_test_context() != NULL) {
4787 HBasicBlock* if_true = inlined_test_context()->if_true(); 4791 HBasicBlock* if_true = inlined_test_context()->if_true();
4788 HBasicBlock* if_false = inlined_test_context()->if_false(); 4792 HBasicBlock* if_false = inlined_test_context()->if_false();
4789 4793
4790 // Pop the return test context from the expression context stack. 4794 // Pop the return test context from the expression context stack.
4791 ASSERT(ast_context() == inlined_test_context()); 4795 ASSERT(ast_context() == inlined_test_context());
4792 ClearInlinedTestContext(); 4796 ClearInlinedTestContext();
4797 delete target_state;
4793 4798
4794 // Forward to the real test context. 4799 // Forward to the real test context.
4795 if (if_true->HasPredecessor()) { 4800 if (if_true->HasPredecessor()) {
4796 if_true->SetJoinId(expr->id()); 4801 if_true->SetJoinId(expr->id());
4797 HBasicBlock* true_target = TestContext::cast(ast_context())->if_true(); 4802 HBasicBlock* true_target = TestContext::cast(ast_context())->if_true();
4798 if_true->Goto(true_target, drop_extra); 4803 if_true->Goto(true_target, function_state()->drop_extra());
4799 } 4804 }
4800 if (if_false->HasPredecessor()) { 4805 if (if_false->HasPredecessor()) {
4801 if_false->SetJoinId(expr->id()); 4806 if_false->SetJoinId(expr->id());
4802 HBasicBlock* false_target = TestContext::cast(ast_context())->if_false(); 4807 HBasicBlock* false_target = TestContext::cast(ast_context())->if_false();
4803 if_false->Goto(false_target, drop_extra); 4808 if_false->Goto(false_target, function_state()->drop_extra());
4804 } 4809 }
4805 set_current_block(NULL); 4810 set_current_block(NULL);
4811 return true;
4806 4812
4807 } else if (function_return()->HasPredecessor()) { 4813 } else if (function_return()->HasPredecessor()) {
4808 function_return()->SetJoinId(expr->id()); 4814 function_return()->SetJoinId(expr->id());
4809 set_current_block(function_return()); 4815 set_current_block(function_return());
4810 } else { 4816 } else {
4811 set_current_block(NULL); 4817 set_current_block(NULL);
4812 } 4818 }
4813 4819 delete target_state;
4814 return true; 4820 return true;
4815 } 4821 }
4816 4822
4817 4823
4818 bool HGraphBuilder::TryInlineBuiltinFunction(Call* expr, 4824 bool HGraphBuilder::TryInlineBuiltinFunction(Call* expr,
4819 HValue* receiver, 4825 HValue* receiver,
4820 Handle<Map> receiver_map, 4826 Handle<Map> receiver_map,
4821 CheckType check_type) { 4827 CheckType check_type) {
4822 ASSERT(check_type != RECEIVER_MAP_CHECK || !receiver_map.is_null()); 4828 ASSERT(check_type != RECEIVER_MAP_CHECK || !receiver_map.is_null());
4823 // Try to inline calls like Math.* as operations in the calling function. 4829 // Try to inline calls like Math.* as operations in the calling function.
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
7008 } 7014 }
7009 } 7015 }
7010 7016
7011 #ifdef DEBUG 7017 #ifdef DEBUG
7012 if (graph_ != NULL) graph_->Verify(false); // No full verify. 7018 if (graph_ != NULL) graph_->Verify(false); // No full verify.
7013 if (allocator_ != NULL) allocator_->Verify(); 7019 if (allocator_ != NULL) allocator_->Verify();
7014 #endif 7020 #endif
7015 } 7021 }
7016 7022
7017 } } // namespace v8::internal 7023 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | test/mjsunit/compiler/regress-inline-callfunctionstub.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698