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

Side by Side Diff: src/hydrogen.cc

Issue 5566005: Be more careful about exiting inlined functions in a test context. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years 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 | « no previous file | test/mjsunit/compiler/regress-3260426.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 3959 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 } 3970 }
3971 3971
3972 // Update inlined nodes count. 3972 // Update inlined nodes count.
3973 inlined_count_ += nodes_added; 3973 inlined_count_ += nodes_added;
3974 3974
3975 if (FLAG_trace_inlining) TraceInline(target, true); 3975 if (FLAG_trace_inlining) TraceInline(target, true);
3976 3976
3977 if (body->HasExit()) { 3977 if (body->HasExit()) {
3978 // Add a return of undefined if control can fall off the body. In a 3978 // Add a return of undefined if control can fall off the body. In a
3979 // test context, undefined is false. 3979 // test context, undefined is false.
3980 HValue* return_value = NULL; 3980 HValue* return_value = graph()->GetConstantUndefined();
3981 HBasicBlock* target = NULL;
3982 if (test_context == NULL) { 3981 if (test_context == NULL) {
3983 ASSERT(function_return_ != NULL); 3982 ASSERT(function_return_ != NULL);
3984 return_value = graph()->GetConstantUndefined(); 3983 body->exit_block()->AddLeaveInlined(return_value, function_return_);
3985 target = function_return_;
3986 } else { 3984 } else {
3987 return_value = graph()->GetConstantFalse(); 3985 // The graph builder assumes control can reach both branches of a
3988 target = test_context->if_false(); 3986 // test, so we materialize the undefined value and test it rather than
3987 // simply jumping to the false target.
3988 //
3989 // TODO(3168478): refactor to avoid this.
3990 HBasicBlock* materialize_true = graph()->CreateBasicBlock();
3991 HBasicBlock* materialize_false = graph()->CreateBasicBlock();
3992 HBranch* branch =
3993 new HBranch(materialize_true, materialize_false, return_value);
3994 body->exit_block()->Finish(branch);
3995
3996 materialize_true->AddLeaveInlined(graph()->GetConstantTrue(),
3997 test_context->if_true());
3998 materialize_false->AddLeaveInlined(graph()->GetConstantFalse(),
3999 test_context->if_false());
3989 } 4000 }
3990 body->exit_block()->AddLeaveInlined(return_value, target);
3991 body->set_exit_block(NULL); 4001 body->set_exit_block(NULL);
3992 } 4002 }
3993 4003
3994 // Record the environment at the inlined function call. 4004 // Record the environment at the inlined function call.
3995 AddSimulate(expr->ReturnId()); 4005 AddSimulate(expr->ReturnId());
3996 4006
3997 // Jump to the function entry (without re-recording the environment). 4007 // Jump to the function entry (without re-recording the environment).
3998 subgraph()->exit_block()->Finish(new HGoto(body->entry_block())); 4008 subgraph()->exit_block()->Finish(new HGoto(body->entry_block()));
3999 4009
4000 // Fix up the function exits. 4010 // Fix up the function exits.
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
5531 } 5541 }
5532 5542
5533 #ifdef DEBUG 5543 #ifdef DEBUG
5534 if (graph_ != NULL) graph_->Verify(); 5544 if (graph_ != NULL) graph_->Verify();
5535 if (chunk_ != NULL) chunk_->Verify(); 5545 if (chunk_ != NULL) chunk_->Verify();
5536 if (allocator_ != NULL) allocator_->Verify(); 5546 if (allocator_ != NULL) allocator_->Verify();
5537 #endif 5547 #endif
5538 } 5548 }
5539 5549
5540 } } // namespace v8::internal 5550 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-3260426.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698