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

Side by Side Diff: src/hydrogen.cc

Issue 6615010: Refactor translation of short-circuit logical operations to avoid subgraphs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build/ia32
Patch Set: Created 9 years, 9 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 | « no previous file | no next file » | 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 4897 matching lines...) Expand 10 before | Expand all | Expand 10 after
4908 4908
4909 // Translate right subexpression by visiting it in the same AST 4909 // Translate right subexpression by visiting it in the same AST
4910 // context as the entire expression. 4910 // context as the entire expression.
4911 set_current_block(eval_right); 4911 set_current_block(eval_right);
4912 Visit(expr->right()); 4912 Visit(expr->right());
4913 4913
4914 } else if (ast_context()->IsValue()) { 4914 } else if (ast_context()->IsValue()) {
4915 VISIT_FOR_VALUE(expr->left()); 4915 VISIT_FOR_VALUE(expr->left());
4916 ASSERT(current_block() != NULL); 4916 ASSERT(current_block() != NULL);
4917 4917
4918 HValue* left = Top();
4919 HEnvironment* environment_copy = environment()->Copy();
4920 environment_copy->Pop();
4921 HSubgraph* right_subgraph;
4922 right_subgraph = CreateBranchSubgraph(environment_copy);
4923 ADD_TO_SUBGRAPH(right_subgraph, expr->right());
4924
4925 ASSERT(current_block() != NULL &&
4926 right_subgraph->exit_block() != NULL);
4927 // We need an extra block to maintain edge-split form. 4918 // We need an extra block to maintain edge-split form.
4928 HBasicBlock* empty_block = graph()->CreateBasicBlock(); 4919 HBasicBlock* empty_block = graph()->CreateBasicBlock();
4929 HBasicBlock* join_block = graph()->CreateBasicBlock(); 4920 HBasicBlock* eval_right = graph()->CreateBasicBlock();
4921 HTest* test = is_logical_and
4922 ? new HTest(Top(), eval_right, empty_block)
4923 : new HTest(Top(), empty_block, eval_right);
4924 current_block()->Finish(test);
4930 4925
4931 HTest* test = is_logical_and 4926 set_current_block(eval_right);
4932 ? new HTest(left, right_subgraph->entry_block(), empty_block) 4927 Drop(1); // Value of the left subexpression.
4933 : new HTest(left, empty_block, right_subgraph->entry_block()); 4928 VISIT_FOR_VALUE(expr->right());
4934 current_block()->Finish(test); 4929
4935 empty_block->Goto(join_block); 4930 HBasicBlock* join_block =
4936 right_subgraph->exit_block()->Goto(join_block); 4931 CreateJoin(empty_block, current_block(), expr->id());
4937 join_block->SetJoinId(expr->id());
4938 set_current_block(join_block); 4932 set_current_block(join_block);
4939 ast_context()->ReturnValue(Pop()); 4933 ast_context()->ReturnValue(Pop());
4934
4940 } else { 4935 } else {
4941 ASSERT(ast_context()->IsEffect()); 4936 ASSERT(ast_context()->IsEffect());
4942 // In an effect context, we don't need the value of the left 4937 // In an effect context, we don't need the value of the left
4943 // subexpression, only its control flow and side effects. We need an 4938 // subexpression, only its control flow and side effects. We need an
4944 // extra block to maintain edge-split form. 4939 // extra block to maintain edge-split form.
4945 HBasicBlock* empty_block = graph()->CreateBasicBlock(); 4940 HBasicBlock* empty_block = graph()->CreateBasicBlock();
4946 HBasicBlock* right_block = graph()->CreateBasicBlock(); 4941 HBasicBlock* right_block = graph()->CreateBasicBlock();
4947 HBasicBlock* join_block = graph()->CreateBasicBlock(); 4942 HBasicBlock* join_block = graph()->CreateBasicBlock();
4948 if (is_logical_and) { 4943 if (is_logical_and) {
4949 VISIT_FOR_CONTROL(expr->left(), right_block, empty_block); 4944 VISIT_FOR_CONTROL(expr->left(), right_block, empty_block);
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
6007 } 6002 }
6008 } 6003 }
6009 6004
6010 #ifdef DEBUG 6005 #ifdef DEBUG
6011 if (graph_ != NULL) graph_->Verify(); 6006 if (graph_ != NULL) graph_->Verify();
6012 if (allocator_ != NULL) allocator_->Verify(); 6007 if (allocator_ != NULL) allocator_->Verify();
6013 #endif 6008 #endif
6014 } 6009 }
6015 6010
6016 } } // namespace v8::internal 6011 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698